Re: PHP-DB Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In article <20031218214045.78003.qmail@xxxxxxxxxxxx>, john@xxxxxxxxxx 
says...
> *Sorry if this is a duplicate*
> 
> Using mySQL db to store my data. Using a select statement on my PHP page.
> When it lists out the data it seems to be skipping the first row. Any ideas?
> 
Without seeing your code, I'll have to guess that you are accessing the 
result set once more than you think you are. This snippet from the manual 
shows how to use mysql_fetch_array; if you were to use another 
mysql_fetch_array before the while structure, you would get exactly the 
result you describe. If this isn't the problem, post your code.

<?php 
   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"); 

   while ($row = mysql_fetch_array($result, MYSQL_NUM)) { 
       printf ("ID: %s  Name: %s", $row[0], $row[1]);   
   } 

   mysql_free_result($result); 
?>


Cheers
-- 
Quod subigo farinam

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux