Jump to content

results of select query omit 1 line


curtis_b

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!

Curt
Link to comment
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.

XenoPhage
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.