Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    75
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Pulling an ID from your database.

    Hi, I'm having issues with trying to pull the ID out correctly.
    This is the ideal way I want the ID to be pulled.

    http://a7.sphotos.ak.fbcdn.net/hphot..._3402533_n.jpg

    But then it always pulls the ID like this and stacks the number ID ontop of each other and I want it to have separate DIVS.

    http://photos-e.ak.fbcdn.net/hphotos..._3422285_n.jpg

    This is the code that I'm using. Tell me what I'm doing wrong.

    PHP Code:
    <?
    mysql_connect
    ("localhost""mysql_user""mysql_password") or
        die(
    "Could not connect: " mysql_error());
    mysql_select_db("mydb");

    $result mysql_query("SELECT id, name FROM mytable");

    echo 
    "<div class=\"body_resize\"><div class=\"left\"><br /><span class='date'>$timedate</span><br /><br />";
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) {
        
    printf("<h2>#%s</h2>"$row["id"], $row["name"]);
    }

    mysql_free_result($result);

    echo 
    "<br /><div class=\"comment_gravatar left\"><img alt=\"\" src=\"http://photos-b.ak.fbcdn.net/hphotos-ak-snc6/229186_219276548101072_100000561868489_827154_8135363_n.jpg\" height=\"32\" width=\"32\" /></div><p>Posted By $name<br><br /><p>$message</p><br></div><div class=\"clr\"></div></div>";
    if (
    $ip==$userip && $delcom==1) {
    ?>
    Last edited by Inigoesdr; 05-21-2011 at 05:14 AM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Firstly please read the link in my signature.

    Secondly you might want to try moving your second <div> into your while() loop.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #3
    New Coder
    Join Date
    Jan 2011
    Posts
    75
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by tangoforce View Post
    Firstly please read the link in my signature.

    Secondly you might want to try moving your second <div> into your while() loop.


    Thanks for the 1st link. and the second one. I don't have a which() in there.. I think I know what your talking about, but I don't have any in there.

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    he's talking the WHILE loop and you have one there;

    PHP Code:
    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) {
    printf("<h2>#%s</h2>"$row["id"], $row["name"]);


  • #5
    New Coder
    Join Date
    Jan 2011
    Posts
    75
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by angst View Post
    he's talking the WHILE loop and you have one there;

    PHP Code:
    while ($row mysql_fetch_array($resultMYSQL_ASSOC)) {
    printf("<h2>#%s</h2>"$row["id"], $row["name"]);

    Ohh!! Thanks I see it now, I wasn't paying attention to that. Thanks, I'll see if I can fix my errors and see if that works.

    No, nothing, it's still the same. Just that the div is positioned differently, I need to figure out how to stop the numbers from stacking on top of each other and have them on different layers which is supposed to be the user's post. I'm trying to pull the number ID from the database and display it on the user's comment so they can see what their post number is.
    Last edited by xiong_ster123; 05-21-2011 at 05:39 AM.


  •  

    Posting Permissions

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