473,395 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

a questions about mysql_fetch_array()

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
1 1549
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: james | last post by:
I am new to PHP and am trying to run a simple query and display the result, with no luck. Here is the code I am using. <?php //start session session_start(); //store cmpid from querystring...
4
by: Theo | last post by:
hi all this is probably another simple one, but the web doesnt seem to have an answer that I can find. Veeeery simple code. each row has 10 columns. require('db.php'); $query = "SELECT *...
8
by: frizzle | last post by:
Hi there, I have two short questions: 1st: I have a site with a mysql DB. There are 3 admins. They're stored in a table called "admin". Fields in there are 'id','name','passw'. If i use the...
15
by: Good Man | last post by:
Hey there I have a dumb question.... Let's say i have a database full of 4000 people.... I select everything from the database by: $result = mysql_query("SELECT * FROM People");
2
by: Dave Moore | last post by:
Hi All, I've got a simple query hopefully somebody can clear up for me. I need to make a query on a database to select a set of table rows, using something like: $result = mysql_query($query);...
4
by: Marcel Brekelmans | last post by:
Hello, I seem to get an extra empty field in every 'mysql_fetch_array' command I issue. For example: I have a simple table 'tblName': ID Name 1 Jane 2 Joe 2 Doe
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
3
by: monomaniac21 | last post by:
hi all im querying a db for two rows which are always returned. how can i reference each row and output its contents without using a while loop. ive tried: $row = mysql_fetch_array($result);...
2
by: William Gill | last post by:
given the query: SELECT * FROM customers left join addresses on customer.cusid=addresses.cusid The mysql monitor returns all fields from both tables, including repeating the field matching...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.