By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,748 Members | 1,506 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,748 IT Pros & Developers. It's quick & easy.

a questions about mysql_fetch_array()

P: n/a
whenever i use this, i'm leaving out one item from the array. in other
words, one row from the table i'm querying won't show up. i'm new at
php, and this is probably a simple thing, but please help of you can.
here's an example that leaves out the most recent submission:

$query = "SELECT topic, message, author, DATE_FORMAT(posted, '%M %e,
%Y') AS d FROM messageboard ORDER BY posted DESC";

$result = @mysql_query ($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC) ) {

echo"<p> {$row['topic']}<br>
{$row['message']}
<br>Posted by {$row['author']} on {$row['d']}
<br>";

}
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <4c**************************@posting.google.com >, lsarg wrote:
whenever i use this, i'm leaving out one item from the array. in other
words, one row from the table i'm querying won't show up. i'm new at
php, and this is probably a simple thing, but please help of you can.
here's an example that leaves out the most recent submission:

$query = "SELECT topic, message, author, DATE_FORMAT(posted, '%M %e,
%Y') AS d FROM messageboard ORDER BY posted DESC";

$result = @mysql_query ($query);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
here $row contains the first row that is returned from your query
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC) ) {
the first time you here, $row will containt the 2nd row from your query }


Suggestion: Leave the first $row = mysql_fetch_assoc($result) away.

--
http://home.mysth.be/~timvw
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.