randydg Posted November 23, 2009 Share Posted November 23, 2009 The following code sometimes pulls up old information instead of the correct info. any help would be greatfull The form submit <?php // Status // 1. inshop // 2 in progress // 3 pending // 4 to be picked up // 5 Done. Out of office. $db = mysql_connect("x","x","x") or die("Couldn't connect"); mysql_select_db("gcs_gowershop",$db) or die("Couldn't select database"); $query="SELECT * FROM `calls` WHERE `status` = '1' AND `priority` != 1 ORDER BY `date` "; $result=mysql_query($query); $num=mysql_numrows($result); print '<table width="100%" border="0">'; print "<tr><td><b>In Shop: $num <br></b></td></tr>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $customer=mysql_result($result,$i,"customer"); // $worksheetnum=mysql_result($result,$i,"worksheetnum"); // $worksheetnum =mysql_result($result2,$i,"($_POST['worksheetnum'])"); $worksheet=mysql_result($result,$i,"worksheet"); #Find customer name out of customer field $query_customer="SELECT `name` FROM `customers` WHERE `id` = $customer"; $result_customer=mysql_query($query_customer); $numa=mysql_numrows($result_customer); $n=0; while ($n < $numa) { $customer=mysql_result($result_customer,$n,"name"); $n++; }; #end //View Inshop print '<FORM ACTION="GWS_online_lookup.php" method=post>'; print "<tr><td width=11%><input type=\"hidden\" name=\"wo\" value=$id><input type=\"submit\" value=\"View\"/>"; print "</td>"; print '<td align="left" width="29%">'; // print '<b><h3>'; print "$customer"; // print '</b></h3>'; print '</td><td width="24%">'; // print '<b><h3>'; print "$date"; // print '</b></h3>'; print '</td><td width="20%">'; // print '<b><h3>'; print "$time"; // print '</b></h3>'; print '<td width="16%">'; // print '<b><h3>'; print "WS $id"; // print '</b></h3>'; print '</td>'; print '</form>'; $i++; }; print "</table>"; $worksheetnum = trim(stripslashes($_POST['worksheetnum'])); $customerid = trim(stripslashes($_POST['customerid'])); $id = $_POST['wo']; print $worksheetnum; print "<input type=\"hidden\" name=\"worksheetnum\" value=$worksheetnum>"; print "<input type=\"hidden\" name=\"customerid\" value=$customerid>"; print "<input type=\"hidden\" name=\"wo\" value=$id>"; ?> This code is what the above code submits too <?php $id = $_POST['wo']; //Get Worksheet ID data from database $db = mysql_connect("x","x","x") or die("Couldn't connect"); mysql_select_db("x",$db) or die("Couldn't select database"); $query="SELECT * FROM `calls` WHERE `id` = $id"; $result=mysql_query($query); $num=mysql_numrows($result); $n=0; while ($n < $num) { $customerid=mysql_result($result,$i,"customer"); $worksheetnum=mysql_result($result,$i,"id"); $techid=mysql_result($result,$i,"inshop"); $n++; }; //Get Customer Data from datebase from $customerid $query="SELECT * FROM `customers` WHERE `id` = $customerid"; $result=mysql_query($query); $num=mysql_numrows($result); $n=0; while ($n < $num) { $name=mysql_result($result,$i,"name"); $phone=mysql_result($result,$i,"phone"); $alt=mysql_result($result,$i,"alt"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $n++; }; //Get Worksheet Data from database for $worksheetnum $query="SELECT * FROM `worksheets` WHERE `id` = $worksheetnum"; $result=mysql_query($query); $num=mysql_numrows($result); $n=0; while ($n < $num) { $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $caller=mysql_result($result,$i,"caller"); $equipment=mysql_result($result,$i,"equipment"); $warranty=mysql_result($result,$i,"warranty"); $billable=mysql_result($result,$i,"billable"); $inshopa=mysql_result($result,$i,"inshopa"); $onsite=mysql_result($result,$i,"onsite"); $called=mysql_result($result,$i,"called"); $workproblem=mysql_result($result,$i,"workproblem"); $workperformed=mysql_result($result,$i,"workperformed"); $serial=mysql_result($result,$i,"serial"); $comments=mysql_result($result,$i,"comments"); $dateworked1=mysql_result($result,$i,"dateworked1"); $dateworked2=mysql_result($result,$i,"dateworked2"); $dateworked3=mysql_result($result,$i,"dateworked3"); $timein1=mysql_result($result,$i,"timein1"); $timein2=mysql_result($result,$i,"timein2"); $timein3=mysql_result($result,$i,"timein3"); $timeout1=mysql_result($result,$i,"timeout1"); $timeout2=mysql_result($result,$i,"timeout2"); $timeout3=mysql_result($result,$i,"timeout3"); $techworked1=mysql_result($result,$i,"techworked1"); $techworked2=mysql_result($result,$i,"techworked2"); $techworked3=mysql_result($result,$i,"techworked3"); $quanity1=mysql_result($result,$i,"quanity1"); $quanity2=mysql_result($result,$i,"quanity2"); $quanity3=mysql_result($result,$i,"quanity3"); $quanity4=mysql_result($result,$i,"quanity4"); $quanity5=mysql_result($result,$i,"quanity5"); $quanity6=mysql_result($result,$i,"quanity6"); $description1=mysql_result($result,$i,"description1"); $description2=mysql_result($result,$i,"description2"); $description3 =mysql_result($result,$i,"description3"); $description4=mysql_result($result,$i,"description4"); $description5=mysql_result($result,$i,"description5"); $description6=mysql_result($result,$i,"description6"); $unitprice1=mysql_result($result,$i,"unitprice1"); $unitprice2=mysql_result($result,$i,"unitprice2"); $unitprice3=mysql_result($result,$i,"unitprice3"); $unitprice4=mysql_result($result,$i,"unitprice4"); $unitprice5=mysql_result($result,$i,"unitprice5"); $unitprice6=mysql_result($result,$i,"unitprice6"); $extendedprice1=mysql_result($result,$i,"extendedprice1"); $extendedprice2=mysql_result($result,$i,"extendedprice2"); $extendedprice3=mysql_result($result,$i,"extendedprice3"); $extendedprice4=mysql_result($result,$i,"extendedprice4"); $extendedprice5=mysql_result($result,$i,"extendedprice5"); $extendedprice6=mysql_result($result,$i,"extendedprice6"); $subtotal=mysql_result($result,$i,"subtotal"); $tax=mysql_result($result,$i,"tax"); $totalprice=mysql_result($result,$i,"totalprice"); $n++; }; ?> Quote Link to comment https://forums.phpfreaks.com/topic/182707-pulling-up-wrong-info-need-help/ Share on other sites More sharing options...
mikesta707 Posted November 23, 2009 Share Posted November 23, 2009 What kind of column is date? varchar? datetime? timestamp? is it pulling up the last information on the table, instead of the newest information (IE its ordering in ascending order rather than descending order) Or is it just pulling out random rows? Quote Link to comment https://forums.phpfreaks.com/topic/182707-pulling-up-wrong-info-need-help/#findComment-964335 Share on other sites More sharing options...
randydg Posted November 23, 2009 Author Share Posted November 23, 2009 its supose to pull it up by worksheetnum $worksheetnum = trim(stripslashes($_POST['worksheetnum'])); Entire index code containing the submit form: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script language=" JavaScript" ><!-- function MyReload() { window.location.reload(); } //--></script> </head> <Body onLoad=" MyReload()" > <table width="100%" border="0"> <td width="661"> <img src="image001.JPG"> </td> <td align="right" width="230"> <?php // session_start(); $db = mysql_connect("x","x","x") or die("Couldn't connect"); mysql_select_db("gcs_gowershop",$db) or die("Couldn't select database"); // echo "Your logged in as ".$_SESSION['user']; // $query="SELECT * FROM `calls` WHERE `status` = '1' AND `priority` != 1"; // $result=mysql_query($query); // $num=mysql_numrows($result); // print "<tr><td><b>In Shop: $num <br></b></td></tr>"; // second query in progress // $query2="SELECT * FROM `calls` WHERE `status` = '2'"; // $result2=mysql_query($query2); // $num2=mysql_numrows($result2); // print "<tr><td><b>In Progress: $num2 <br></b></td></tr>"; // third query Pending // $query3="SELECT * FROM `calls` WHERE `status` = '3'"; // $result3=mysql_query($query3); // $num3=mysql_numrows($result3); // print "<tr><td><b>Pending: $num3 <br></b></td></tr>"; // fourth query - priority // $query4="SELECT * FROM `calls` WHERE `status` = '1' AND `priority` = 1"; // $result4=mysql_query($query4); // $num4=mysql_numrows($result4); // print "<tr><td><b>Priority: $num4 <br></b></td></tr>"; // fifth query completed // $query5="SELECT * FROM `calls` WHERE `status` = '5'"; // $result5=mysql_query($query5); // $num5=mysql_numrows($result5); // print "<tr><td><b>completed $num5 <br></b></td></tr>"; ?> <form action="destroy.php" method="post"></form> Your logged in as:<br></td> </table> <table width="100%" border="1"> <tr> <td align="left" valign="top"> <a href="GWS_online_New.php" title="New" target="_blank">Create</a> | <a href="deleteworksheet.php" title="New" target="_blank">Delete</a> </td> </tr> <tr> <td><?php // Status // 1. inshop // 2 in progress // 3 pending // 4 to be picked up // 5 Done. Out of office. $db = mysql_connect("x","x","x") or die("Couldn't connect"); mysql_select_db("gcs_gowershop",$db) or die("Couldn't select database"); $query="SELECT * FROM `calls` WHERE `status` = '1' AND `priority` != 1 ORDER BY `date` "; $result=mysql_query($query); $num=mysql_numrows($result); print '<table width="100%" border="0">'; print "<tr><td><b>In Shop: $num <br></b></td></tr>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $customer=mysql_result($result,$i,"customer"); // $worksheetnum=mysql_result($result,$i,"worksheetnum"); // $worksheetnum =mysql_result($result2,$i,"($_POST['worksheetnum'])"); $worksheet=mysql_result($result,$i,"worksheet"); #Find customer name out of customer field $query_customer="SELECT `name` FROM `customers` WHERE `id` = $customer"; $result_customer=mysql_query($query_customer); $numa=mysql_numrows($result_customer); $n=0; while ($n < $numa) { $customer=mysql_result($result_customer,$n,"name"); $n++; }; #end //View Inshop print '<FORM ACTION="GWS_online_lookup.php" method=post>'; print "<tr><td width=11%><input type=\"hidden\" name=\"wo\" value=$id><input type=\"submit\" value=\"View\"/>"; print "</td>"; print '<td align="left" width="29%">'; // print '<b><h3>'; print "$customer"; // print '</b></h3>'; print '</td><td width="24%">'; // print '<b><h3>'; print "$date"; // print '</b></h3>'; print '</td><td width="20%">'; // print '<b><h3>'; print "$time"; // print '</b></h3>'; print '<td width="16%">'; // print '<b><h3>'; print "WS $id"; // print '</b></h3>'; print '</td>'; print '</form>'; $i++; }; print "</table>"; $worksheetnum = trim(stripslashes($_POST['worksheetnum'])); $customerid = trim(stripslashes($_POST['customerid'])); $id = $_POST['wo']; print $worksheetnum; print "<input type=\"hidden\" name=\"worksheetnum\" value=$worksheetnum>"; print "<input type=\"hidden\" name=\"customerid\" value=$customerid>"; print "<input type=\"hidden\" name=\"wo\" value=$id>"; ?></td> </tr> <tr> <td> <?php //Priority List $query="SELECT * FROM `calls` WHERE `status` = '1' AND `priority` = 1"; $result=mysql_query($query); $num=mysql_numrows($result); print '<table width="100%" border="0">'; print "<tr><td><b>Priority: $num <br></b></td></tr>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $customer=mysql_result($result,$i,"customer"); $worksheet=mysql_result($result,$i,"worksheet"); #Find customer name out of customer field $query_customer="SELECT `name` FROM `customers` WHERE `id` = $customer"; $result_customer=mysql_query($query_customer); $numa=mysql_numrows($result_customer); $n=0; while ($n < $numa) { $customer=mysql_result($result_customer,$n,"name"); $n++; }; #end print '<FORM ACTION="GWS_online_lookup.php" method=post>'; print "<tr><td width=11%><input type=\"hidden\" name=\"wo\" value=$id><input type=\"submit\" value=\"View\"/></td>"; print "</td>"; print '<td align="left" width="29%">'; print '<b><h5>'; print "$customer"; print '</b></h5>'; print '</td><td width="24%">'; print '<b><h5>'; print "$date"; print '</b></h5>'; print '</td><td width="20%">'; print '<b><h5>'; print "$time"; print '</b></h5>'; print '<td width="16%">'; print '<b><h5>'; print "WS $id"; print '</b></h5>'; print '</td>'; print '</form>'; $i++; }; print "</table>"; $worksheetnum = trim(stripslashes($_POST['worksheetnum'])); $customerid = trim(stripslashes($_POST['customerid'])); $id = $_POST['wo']; print $worksheetnum; print "<input type=\"hidden\" name=\"worksheetnum\" value=$worksheetnum>"; print "<input type=\"hidden\" name=\"customerid\" value=$customerid>"; print "<input type=\"hidden\" name=\"wo\" value=$id>"; ?></td> </tr> <tr> <td> <?php //In Progress $query="SELECT * FROM `calls` WHERE `status` = '2'"; $result=mysql_query($query); $num=mysql_numrows($result); print '<table width="100%" border="0">'; print "<tr><td colspan=\"3\"><b>In Progress: $num <br></b></td></tr>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $customer=mysql_result($result,$i,"customer"); $worksheet=mysql_result($result,$i,"worksheet"); // $worksheetnum = mysql_result($result,$i,"worksheetnum"); #Find customer name out of customer field $query_customer="SELECT `name` FROM `customers` WHERE `id` = $customer"; $result_customer=mysql_query($query_customer); $numa=mysql_numrows($result_customer); $n=0; while ($n < $numa) { $customer=mysql_result($result_customer,$n,"name"); $n++; }; #end print '<FORM ACTION="GWS_online_lookup.php" method=post>'; print "<tr><td width=11%><input type=\"hidden\" name=\"wo\" value=$id><input type=\"submit\" value=\"View\"/></td>"; print "</td>"; print '<td align="left" width="29%">'; // print '<b><h3>'; print "$customer"; // print '</b></h3>'; print '</td><td width="24%">'; // print '<b><h3>'; print "$date"; // print '</b></h3>'; print '</td><td width="20%">'; // print '<b><h3>'; print "$time"; // print '</b></h3>'; print '<td width="16%">'; // print '<b><h3>'; print "WS $id"; // print '</b></h3>'; print '</td>'; print '</form>'; $i++; }; print "</table>"; $customerid = trim(stripslashes($_POST['customerid'])); $id = $_POST['wo']; print $worksheetnum; print "<input type=\"hidden\" name=\"worksheetnum\" value=$worksheetnum>"; print "<input type=\"hidden\" name=\"customerid\" value=$customerid>"; print "<input type=\"hidden\" name=\"wo\" value=$id>"; ?></td> </tr> <tr> <td> <?php //In Pending $query="SELECT * FROM `calls` WHERE `status` = '3'"; $result=mysql_query($query); $num=mysql_numrows($result); print '<table width="100%" border="0">'; print "<tr><td><b>Pending: $num <br></b></td></tr>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $customer=mysql_result($result,$i,"customer"); $worksheet=mysql_result($result,$i,"worksheet"); #Find customer name out of customer field $query_customer="SELECT `name` FROM `customers` WHERE `id` = $customer"; $result_customer=mysql_query($query_customer); $numa=mysql_numrows($result_customer); $n=0; while ($n < $numa) { $customer=mysql_result($result_customer,$n,"name"); $n++; }; #end print '<FORM ACTION="GWS_online_lookup.php" method=post>'; print "<tr><td width=11%><input type=\"hidden\" name=\"wo\" value=$id><input type=\"submit\" value=\"View\"/></td>"; print "</td>"; print '<td align="left" width="29%">'; // print '<b><h3>'; print "$customer"; // print '</b></h3>'; print '</td><td width="24%">'; // print '<b><h3>'; print "$date"; // print '</b></h3>'; print '</td><td width="20%">'; // print '<b><h3>'; print "$time"; // print '</b></h3>'; print '<td width="16%">'; // print '<b><h3>'; print "WS $id"; // print '</b></h3>'; print '</td>'; print '</form>'; $i++; }; print "</table>"; ?></td> </tr> <tr> <td> <?php //In Completed $query="SELECT * FROM `calls` WHERE `status` = '4'"; $result=mysql_query($query); $num=mysql_numrows($result); print '<table width="100%" border="0">'; print "<tr><td colspan=\"4\"><b>To be Picked up: $num <br></b></td></tr>"; $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $date=mysql_result($result,$i,"date"); $time=mysql_result($result,$i,"time"); $customer=mysql_result($result,$i,"customer"); $worksheet=mysql_result($result,$i,"worksheet"); #Find customer name out of customer field $query_customer="SELECT `name` FROM `customers` WHERE `id` = $customer"; $result_customer=mysql_query($query_customer); $numa=mysql_numrows($result_customer); $n=0; while ($n < $numa) { $customer=mysql_result($result_customer,$n,"name"); $n++; }; #end print '<FORM ACTION="GWS_online_lookup.php" method=post>'; print "<tr><td width=11%><input type=\"hidden\" name=\"wo\" value=$id><input type=\"submit\" value=\"View\"/></td>"; print "</td>"; print '<td align="left" width="29%">'; // print '<b><h3>'; print "$customer"; // print '</b></h3>'; print '</td><td width="24%">'; // print '<b><h3>'; print "$date"; // print '</b></h3>'; print '</td><td width="20%">'; // print '<b><h3>'; print "$time"; // print '</b></h3>'; print '<td width="16%">'; // print '<b><h3>'; print "WS $id"; // print '</b></h3>'; print '</td>'; print '</form>'; $i++; }; print "</table>"; ?></td> </tr> <tr> <td> </td></tr> <tr> <td align="left" valign="top"> <a href="call_app/emailform.html">Message</a> | <a href="completed.php" title="Completed">Completed</a> |</td> </tr> </table> <p> </p> <p> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/182707-pulling-up-wrong-info-need-help/#findComment-964341 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.