SELECT * FROM没有在MySQL表中获取第一行

I'm not certain if this is a bug or a stupid error on my part, but I'd like to display a list of plays and theatrical performances from a database.

I can get it to display from row/entry 2 downwards fine - but it won't display the first row at all. Where there is only one entry, nothing is displayed. I've tried altering the id's of each, but it seems to just be the first one entered that isn't picked up, but ones entered after are.

The code to display the table is below.

<?php
$con = mysql_connect("localhost"," me "," mypass word");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

  mysql_select_db(" database name", $con);

  $data = mysql_query("SELECT * FROM table") 
 or die(mysql_error());
 $info = mysql_fetch_array( $data );

 while($info = mysql_fetch_array( $data )) 
 {
 Print "<tr><td style='background-color: #D3D3D3;  '>";
 Print " ".$info['title'] . " ";
 Print "</td>";

...etc...

   Print "</td> </tr>";
 } 

?>
    </table>

It seems quite simple but I can't figure it out at all. Any help much appreciated.

remove this line

 $info = mysql_fetch_array( $data );

you are using it twice. above and in while loop

You are calling mysql_fetch_array() twice.

Remove the first:

 $info = mysql_fetch_array( $data );

remove this line

 $info = mysql_fetch_array( $data );

Try this

<?php
$con = mysql_connect("localhost"," me "," mypass word");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

  mysql_select_db(" database name", $con);

  $data = mysql_query("SELECT * FROM table") 
 or die(mysql_error());

 while($info = mysql_fetch_array( $data )) 
 {
 Print "<tr><td style='background-color: #D3D3D3;  '>";
 Print " ".$info['title'] . " ";
 Print "</td>";

You are calling the mysql_fetch_array() two times - in the while loop and above it.

 $info = mysql_fetch_array( $data );

It because, you are fetching the array twice:

$info = mysql_fetch_array( $data );

Here your arrays current first element is fetched and current element is set to second one. So the following line fetches the array elements from the second element.

while($info = mysql_fetch_array( $data ))

Just remove the line

$info = mysql_fetch_array( $data );

And done.

It ain't a bug.

Whenever you send mysql_fetch_array( $data ); it fetches one row and automatically rises the internal row identifier property. The next time when you call the same function it starts from the second row.

It is unpractical to use assignment in conjunction with PHP mysql functions outside a loop, when demonstrated behavior is not exactly what you want to do.

By removing the $info = mysql_fetch_array( $data ); row your code will function as expected.