Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-29-2011, 09:33 AM   PM User | #1
Krentenbol
New Coder

 
Join Date: Sep 2011
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
Krentenbol is an unknown quantity at this point
php auto increment doesn't work when showing rows

This is my code:


PHP 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

Last edited by Krentenbol; 11-29-2011 at 02:31 PM..
Krentenbol is offline   Reply With Quote
Old 11-29-2011, 06:04 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
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.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:29 AM.


Advertisement
Log in to turn off these ads.