...

View Full Version : Resolved php auto increment doesn't work when showing rows



Krentenbol
11-29-2011, 09:33 AM
This is my code:



<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die(mysql_error());
}
$i=1;
mysql_select_db("list", $con);

$result = mysql_query("SELECT * FROM users
WHERE id='$i'");

while($row = mysql_fetch_array($result))
{
echo $row['id'] . " " . $row['name'];
echo "<br />";

echo $row['id'] . " " . $row['name'];

echo "<br />";
$i++;

}
?>

For some reason it just doesn't increases so I get:

1 John
1 John

oracleguy
11-29-2011, 06:04 PM
You are only pulling one row from your users table, the row with the ID of 1 so that is why you'll only see that one printed out in your while loop.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum