SitePoint Sponsor

User Tag List

Results 1 to 23 of 23
  1. #1
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow The id numbers don't display properly???

    What I am trying to do is to display the id number and parent_id number in a url. However that isn't working for me. Can someone please tell me how I could achieve that? Please don't alter my code just tell me how I can achieve what I have asked. Thanks in advance.

    PHP Code:
    // more code is here

    require_once 'config.php';
    // more code is here

    // Perform MySQL query on only the current page number's results
    // get the clearing sale from the database
    $sql "SELECT * FROM
      clearingsales
      ORDER BY propertyname
      LIMIT 
    $from$max_results";
    if(
    $debug == TRUE)
      echo 
    '<p>DEBUG2: '.$sql.'</p>';
    $result mysql_query($sql)
      or die (
    'Could not query because: ' mysql_error());

    if (
    mysql_num_rows($result) == 0)
    {
      echo 
    'No clearing sales to be displayed.';
      exit;
    }
    // display the clearing sale
    while($row mysql_fetch_assoc($result))
    {
      
    $propertyname stripslashes($row['propertyname']);
      echo 
    '<center><b>'.$propertyname.'</b></center>';
      echo 
    "<center>".$row['date']." at ".$row['time']."<br />";
      echo 
    "Account: ".$row['accountname']."<br />";
      echo 
    $row['comments']."</center><br />";
      echo 
    '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
      for(
    $x=1;$x<18;$x++)
      {
        
    $message '';
        
    $category '';
        
    $mess 'txt'.$x;
        if(isset(
    $row[$mess]))
        {
          
    $message stripslashes($row[$mess]);
        }
        
    $cat 'select'.$x;
        if(isset(
    $row[$cat]))
        {
          
    $category stripslashes($row[$cat]);
        }
        if(!empty(
    $message) && !empty($category))
        {
          echo 
    '<tr>';
          echo 
    '<td width="20%" valign="top"><div class="titletxt">'.$select.'</div></td>';
          echo 
    '<td width="50%" valign="top">'.$txt.'</td></tr>';
        }
    // get the id number from the database for the url
        
    $id $row['id'];
      }
      echo 
    '</table><br />';
      echo 
    'Click on the image to see the larger image.<br />';

    // get the photos for that clearing sale from the database
      
    $sql "SELECT *
        FROM clearingsales_photos
        WHERE parent_id = '"
    .mysql_real_escape_string($row['id'])."'";
      if(
    $debug == TRUE)
        echo 
    '<p>DEBUG3: '.$sql.'</p>';
      
    $result2 mysql_query($sql)
        or die (
    'Could not query because: ' mysql_error());

    // display the photos for that clearing sale
      
    while ($row2 mysql_fetch_assoc($result2))
      {
        echo 
    '<a href="javascript:void(0)" onClick="popWin(\''.$images_location_large.$row2['filename'].'.htm\', \'\', \''.$popup_width.'\', \''.$popup_height.'\')"><img src="'.$images_location.$row2['photos'].'" border="0" /></a> ';
    // get the parent_id number from the database for the url below
        
    $parent_id $row2['parent_id'];
      }
    }
    // the id and parent_id number url
    echo "<a href=delete_clearing_sale.php?id=".$id."&parent_id=".$parent_id.">DELETE</a> ";
    echo 
    "<a href=edit_clearing_sale.php?id=".$id."&parent_id=".$parent_id.">EDIT</a>";

    // more code is here 
    Last edited by cturner01; Jun 16, 2007 at 21:39.

  2. #2
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, Maybe i can help you, but i dont really understand what you are doing in these lines....

    PHP Code:
    $sql "SELECT * FROM clearingsales_photos WHERE parent_id = '".mysql_real_escape_string($row['id'])."'";

      if(
    $debug == TRUE)
        echo 
    '<p>DEBUG3: '.$sql.'</p>';
      
    $result2 mysql_query($sql)
        or die (
    'Could not query because: ' mysql_error());
      while (
    $row2 mysql_fetch_assoc($result2))
      {
        echo 
    '<a href="javascript:void(0)" onClick="popWin(\''.$images_location_large.$row2['filename'].'.htm\', \'\', \''.$popup_width.'\', \''.$popup_height.'\')"><img src="'.$images_location.$row2['photos'].'" border="0" /></a> ';

        
    $parent_id $row2['parent_id'];
      }
    }
    // the id number url is here

    echo "<a href=delete_clearing_sale.php?id=".$id."&parent_id=".$parent_id.">DELETE</a> ";
    echo 
    "<a href=edit_clearing_sale.php?id=".$id."&parent_id=".$parent_id.">EDIT</a>";

    // more code is here 
    Maybe if you are more explicit in what you whant to do and add more comments to yout code, i can help you

  3. #3
    SitePoint Zealot t0WL337's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Ontario!
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    looking at your code, try echoing out $id right after you defined
    $id = $row['id'];
    then for $parent_id do the same and see if it is actually returning something.

    Just to be sure, is this the part you are having problems with?
    PHP Code:
    echo "<a href=delete_clearing_sale.php?id=".$id."&parent_id=".$parent_id.">DELETE</a> "
    echo 
    "<a href=edit_clearing_sale.php?id=".$id."&parent_id=".$parent_id.">EDIT</a>"
    <3php && SitePoint ?>

  4. #4
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes t0WL337 that is the part of my code that I am having problems with.

    I have placed more comments in the code.

  5. #5
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it seems like he is getting the id from that table for each of the records...

    and at the end those buttons

  6. #6
    SitePoint Zealot t0WL337's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Ontario!
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you try what I posted before?

    Yes I agree, it is strange how the while loops are set up.

    Do you want to have multiple of those links? Or just the two?
    <3php && SitePoint ?>

  7. #7
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    let me tell u if the problem is this...

    You are trying to make a link for each of the images u have stored in a database... adding to that url some querystring which is the id and the id_parent and you dont get those ids correctly

  8. #8
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, i have been analyzing your code... and according to that, the value of the $id and $id_parent is the same isn't it?

    look this line... you are giving a value to $id

    PHP Code:
    $id $row['id']; 
    and then you do this:

    PHP Code:
    $sql "SELECT *
        FROM clearingsales_photos
        WHERE parent_id = '"
    .mysql_real_escape_string($row['id'])."'"
    wich means that the result will have the parent_id equals to the $id

    and finally you do this:

    PHP Code:
    while ($row2 mysql_fetch_assoc($result2))
      {
        echo 
    '<a href="javascript:void(0)" onClick="popWin(\''.$images_location_large.$row2['filename'].'.htm\', \'\', \''.$popup_width.'\', \''.$popup_height.'\')"><img src="'.$images_location.$row2['photos'].'" border="0" /></a> ';
    // get the parent_id number from the database for the url below
        
    $parent_id $row2['parent_id'];
      } 
    as I told you before... you are giving the same value to both variables....

    well at least thats what i think...

  9. #9
    SitePoint Zealot t0WL337's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Ontario!
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If that is true, then it could still be possible for the links to be active though. Depending on actual ids in the tables.
    <3php && SitePoint ?>

  10. #10
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When the user clicks on the delete link the code is suppose to display the id number and parent_id number in the url string. So that the the next page can delete the clearing sale as well as the photos that match that clearing sale. With the modify link the same thing is suppose to happen with the url string. So that the next page can display the content for that row in the database. I hope all of that is clear enough.

  11. #11
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have understood what everyone has said. I have tried what everyone has said to do. However I am not getting anywhere. So can someone please help me solve this problem because I am getting stressed out that I am getting nowhere? By the way someone has helped me write that code.

  12. #12
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes dont worry, we will solve it right now ...

    ok when you run that code you paste.. wich is the result in the links...

  13. #13
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dunkel View Post
    ok when you run that code you paste.. wich is the result in the links...
    I don't understand what you mean by which is the result in the links. Can you please explain to me what you mean?

  14. #14
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cturner01 View Post
    I don't understand what you mean by which is the result in the links. Can you please explain to me what you mean?
    yes in the delete button which is the url...

    delete_clearing_sale.php?id={?}&parent_id={?}

  15. #15
    SitePoint Zealot t0WL337's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Ontario!
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think he wants you to test if the link that DOES NOT DELETE ANYTHING is working.
    <3php && SitePoint ?>

  16. #16
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dunkel View Post
    yes in the delete button which is the url...

    delete_clearing_sale.php?id={?}&parent_id={?}
    There is a result in the id number that is in the url string. I just hope it is the right id number. I hope that is what you wanted to know.

  17. #17
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cturner01 View Post
    There is a result in the id number that is in the url string. I just hope it is the right id number. I hope that is what you wanted to know.
    then the url string is correct in both buttons?

  18. #18
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by t0WL337 View Post
    I think he wants you to test if the link that DOES NOT DELETE ANYTHING is working.
    You can test the link however the deleting doesn't happen until delete_clearing_sale.php displays.

  19. #19
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dunkel View Post
    then the url string is correct in both buttons?
    Yes, but the parent_id is blank.

  20. #20
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cturner01 View Post
    Yes, but the parent_id is blank.
    oh ok... then first of all lets make this....

    on this lines add an echo...

    PHP Code:
    while ($row2 mysql_fetch_assoc($result2))

      {

        echo 
    '<a href="javascript:void(0)" onClick="popWin(\''.$images_location_large.$row2['filename'].'.htm\', \'\', \''.$popup_width.'\', \''.$popup_height.'\')"><img src="'.$images_location.$row2['photos'].'" border="0" /></a> ';

    // get the parent_id number from the database for the url below

        
    $parent_id $row2['parent_id'];
        
    //-----------HERE ADD THE ECHO LIEK THIS: 
        
    echo $parent_id;
      } 
    then if it shows you the value, then the ploblem is the variable ambit... (i dont know if is the correct word... my english is not as good as i want )

  21. #21
    SitePoint Evangelist cturner01's Avatar
    Join Date
    Jun 2006
    Location
    My computer
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry everyone but I think I know why the parent_id is displaying blank. Before I explain why it is blank, I will explain why I have just realised. I must have been staring at my computer too long. The reason why it is blank is because there is nothing in that row to display. LOL :embrassed:

  22. #22
    SitePoint Enthusiast Dunkel's Avatar
    Join Date
    Jun 2007
    Location
    Mexico
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cturner01 View Post
    Sorry everyone but I think I know why the parent_id is displaying blank. Before I explain why it is blank, I will explain why I have just realised. I must have been staring at my computer too long. The reason why it is blank is because there is nothing in that row to display. LOL :embrassed:
    xD!!!!!!!!!!

    ok cturner dont worry, I hate when it happens to me

    well now you can continue your project

  23. #23
    SitePoint Zealot t0WL337's Avatar
    Join Date
    Mar 2007
    Location
    Ottawa, Ontario!
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol, its cool man. Good luck with your project.
    @ Dunkel kudos for the good advice and helping
    <3php && SitePoint ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •