Jump to content


This topic is now archived and is closed to further replies.


results of select query omit 1 line

Recommended Posts

I'll post some code below, but I don't believe that's where the problem lies.

I'm writing an application for our graphic designers to keep track of proofs online.

[a href=\"http://7cpco.com/proofs/overview.php\" target=\"_blank\"]http://7cpco.com/proofs/overview.php[/a]

As you can see on the page there are (currently) 2 catagories - and I will be adding more after I get this problem solved.

Currently there are 2 results in the top catagory (out for proof) and 1 below (require a revision). The problem is, there really should be 3 in the top and 2 below.

The result set I am getting back from mysql is omiting the first line for each query. If I run the identical query (copy and paste) right in phpMyAdmin, I get the correct results, but from my .php web page, [b]each query is skipping one line and returning everything else[/b].

I have checked the page source to make sure this isn't just a CSS formatting issue.

The queries are pretty simple. For the first catagory - out for proof- I have a column in mysql called Response_y_or_n that auto fills in 'n' upon creation and is later replaced with 'y' when the customer fills out the response form. To return a list of all jobs out to proof I am simply looking for all rows with 'n' for that column.

So my query/loop for that catagory is:

//populate a div full of jobs currently out for proof
$query = "SELECT * FROM proofs where Response_y_or_n='n'";

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo '<div id="wrap"><div class="wrapflow">';
echo '<span class="title">Proofs that we are waiting on:</span><br>';

//labeling the columns
echo '<u><span class="invoice_number">Invoice#</span><span class="customer_orgname">Customer/Org</span><span class="description">Description</span><span class="designer_name">Designer</span><span class="response_target_datetime">Approve by</span><span class="customer_email">Contact</span></u><br>';

while ($row = mysql_fetch_array($result)){

echo '<span class="invoice_number">'.$row['Invoice_Number'].'</span><span class="customer_orgname">'.$row['Customer_OrgName'].'</span><span class="description"> <a href=http://www.7cpco.com/proofs/'.$row['Filename'].'>'.$row['Description'].'</a></span><span class="designer_name">'.$row['Designer_Name'].'</span><span class="response_target_datetime">'.$row['Response_Target_DateTime'].'</span><span class="customer_email"><a href="mailto:'.$row['Customer_Email'].'">'.$row['Customer_Email'].'</span></a><br>';
echo '</div></div><br>';

Thanks for your help!


Share this post

Link to post
Share on other sites
i had this exact problem...

remove this line:

$row = mysql_fetch_array($result) or die(mysql_error());

then it will work

Share this post

Link to post
Share on other sites
WOW! I do not understand why that is, but you were right.

I don't see any solved button, otherwise I'd mark it.

Thanks Joe!

Share this post

Link to post
Share on other sites
its to do with the while line having the same code... you dont really need it twice. its confusing, but there probally some major reason behind it :P there allways is

Share this post

Link to post
Share on other sites
The reason the original code does not work is that the first mysql_fetch_array takes the first result and places it into $row. Think of $results as a stack. Whenever you call mysql_fetch_array, you pop the top result off the stack. So, when you enter the while loop, it pops the next result off and the first one is lost since it was never used anywhere.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.