Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey. I am using two tables, one table called code, is used to store code examples.
    code_id is set to auto_increment and primary key.

    Now, I wanted to add a feedback feature, so I created a table called feedback.

    How it should work: when the user is on code.php?code_id=integer, when they click feedback.php?code_id=integer this all works fine.

    So what I want is for, if they are leaving on my row which index is 5, then I can just select * where code_id is 5.

    The problem is this: after i submit the feedback page to add entries to table feedback, the code_id value is lost. And then at the bottom of the page instead of showing all the feedback entries, it only shows the one(s) you just entered.

    Its quite hard to explain, so http://bfsog.co.uk/code

    Click one of those links, then at the bottom of the page click "leave feedback ..." and then enter something..

    If anyone out there understands all that and can help me, thanks a lot!

    edit: attached feedback.php code

  2.  

  3. #2
    Senior Member Richard S's Avatar
    Join Date
    Jul 2004
    Location
    SW Lonodn
    Posts
    219
    Member #
    6728
    Liked
    3 times
    Hi Bfsog,

    Had a quick look and think I may have found the problem. (not sure, I'm not too good at looking at other s code).

    I think the problem might be in this part:
    PHP Code:
    <?php

        
    include ("db.php");

        
    $query "SELECT * FROM feedback WHERE feed_id ='$feed_id' ORDER BY id DESC";
        
    $result mysql_query($query);
        
    $numrows mysql_num_rows($result);

        if (
    $numrows == "0") {
            echo 
    "No relevant feedback<br><br>";}
        else {
    $numrows 2;
    $numrows--;
        while(
    $row mysql_fetch_array($result))
        {
            echo 
    "<div class=\"description\"><br />";
            echo 
    "Name: $row[name]<br /><br />";
            echo 
    "Message: $row[message]<br /><br />";
            echo 
    "<br><br>";
            echo 
    "</div>";
    $numrows++;
        }}

    ?>
    I'm not sure, but in the top SQL query shouldn't it read:

    $query = "SELECT * FROM feedback WHERE feed_id ='$code_id' ORDER BY id DESC";

    Instead of [B]$feed_id[/B].

  4. #3
    Senior Member seanmiller's Avatar
    Join Date
    Sep 2003
    Location
    Glastonbury, UK
    Posts
    868
    Member #
    3263
    Liked
    1 times
    Can you post the definition of the feedback table please ?

    I can then recreate the scenario and (hopefully) let you know what's wrong when I get home (if nobody else has before me).

    Best Wishes,

    Sean

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Yes Richard you were right. When I first goto the page, $code_id is set, but then $feed_id is set instead once the form is submitted

    so i added

    PHP Code:
        if (isset($feed_id)) {
            
    $sort $feed_id;}
        else {
            
    $sort $id;} 
    Thanks guys.

  6. #5
    Senior Member Richard S's Avatar
    Join Date
    Jul 2004
    Location
    SW Lonodn
    Posts
    219
    Member #
    6728
    Liked
    3 times
    ahh cool,

    Glad you got it sorted.

    (I bet your kicking yourself now )

  7. #6
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Oh yes. However, every time I start a new php project (guestbook, blog etc) the time it takes to see drastic results is shortening rapidly.

    Good sign that I am improving.

  8. #7
    Senior Member Richard S's Avatar
    Join Date
    Jul 2004
    Location
    SW Lonodn
    Posts
    219
    Member #
    6728
    Liked
    3 times
    I know what you mean.

    The most time consuming debug I've ever had was down to misspelling
    'WHERE' as 'WERE' in a sql query. I was kicking myself so hard after that.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:25 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com