curtis_b Posted February 27, 2006 Share Posted February 27, 2006 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 columnsecho '<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 Quote Link to comment https://forums.phpfreaks.com/topic/3694-results-of-select-query-omit-1-line/ Share on other sites More sharing options...
joecooper Posted February 27, 2006 Share Posted February 27, 2006 i had this exact problem...remove this line:$row = mysql_fetch_array($result) or die(mysql_error());then it will work Quote Link to comment https://forums.phpfreaks.com/topic/3694-results-of-select-query-omit-1-line/#findComment-12791 Share on other sites More sharing options...
curtis_b Posted February 27, 2006 Author Share Posted February 27, 2006 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! Quote Link to comment https://forums.phpfreaks.com/topic/3694-results-of-select-query-omit-1-line/#findComment-12802 Share on other sites More sharing options...
wickning1 Posted February 27, 2006 Share Posted February 27, 2006 Glad you're passing along the wisdom joe. :) Quote Link to comment https://forums.phpfreaks.com/topic/3694-results-of-select-query-omit-1-line/#findComment-12810 Share on other sites More sharing options...
joecooper Posted February 28, 2006 Share Posted February 28, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/3694-results-of-select-query-omit-1-line/#findComment-13006 Share on other sites More sharing options...
XenoPhage Posted February 28, 2006 Share Posted February 28, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/3694-results-of-select-query-omit-1-line/#findComment-13093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.