...

View Full Version : Pulling an ID from your database.



xiong_ster123
05-20-2011, 03:05 AM
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/hphotos-ak-snc6/226659_219275201434540_100000561868489_827151_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-ak-snc6/226659_219275204767873_100000561868489_827152_3422285_n.jpg

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


<?
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($result, MYSQL_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) {
?>

tangoforce
05-20-2011, 12:27 PM
Firstly please read the link in my signature.

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

xiong_ster123
05-21-2011, 02:41 AM
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.

angst
05-21-2011, 04:05 AM
he's talking the WHILE loop and you have one there;



while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("<h2>#%s</h2>", $row["id"], $row["name"]);
}

xiong_ster123
05-21-2011, 05:32 AM
he's talking the WHILE loop and you have one there;



while ($row = mysql_fetch_array($result, MYSQL_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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum