Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Everything posted by mikebyrne

  1. I was looking at similar foreach examples and couldnt see any reason why the code im using wouldnt work
  2. Why would this line cause an error foreach($_POST['trackno'] as $orderno=>$text){ Cant figure this out
  3. Now getting the error Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\Admin_files\processed.php on line 12 processed.php <?php include('adminconnect.php'); $tbl1 = 'admin'; //Mark Completed Orders foreach($_POST['order'] as $orderno => $dmy){ $sql = "UPDATE $tbl1 SET Ordercompleted = 1 WHERE OrderNo= '{$orderno}'"; mysql_query($sql) or die("Failed on order {$orderno}"); } //Update Tracking Numbers foreach($_POST['trackno'] as $orderno=>$text){ $text = mysql_real_escape_string(trim($text)); $sql = "UPDATE $tbl1 SET Trackno = '{$text}' WHERE OrderNo= '{$orderno}'"; mysql_query($sql) or die("Failed on order {$orderno}"); } ?> Line 12 is foreach($_POST['trackno'] as $orderno=>$text){
  4. Fixed it, just missing a ' But the button doesnt work. Just trying to fix it now
  5. Thanks for spelling the reasoning out to me it's helped alot I'm getting an error on line 223 which is <td width="172"><input type="text" name="trackno[<?php echo $row['OrderNo];?>]" value="<?php echo htmlspecialchars($row['Trackno']);?>" /></td> the error msg is Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\xampp\htdocs\Admin_files\Unprocessed.php on line 223
  6. Would changing the textbox code to work?? <td width="172"><input type="text" class=""Trackno[<?php echo $row['Trackno];?>]" name="tn" value="" /></td> Im guessing i need to make an array like i have for the checkbox but not sure how to code it
  7. It will place the 1 ok but im not sure how to code for the textboxes and insert the correct info into the Trackno field
  8. When a user ticks the checkbox, fills in the textbox and presses proceed I want my code to put a 1 in the Orderscompleted field and whatever text is in the textbox into my Trackno field. My code is Processed.php <form action = "processed.php" method="post"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data include('adminconnect.php'); $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Ordercompleted = 0"); while( $row = mysql_fetch_array($sql) ) { // loop through and display ?> <tr align="left"> <td width="33"> </td> <td><input type = "checkbox" name="order[<?php echo $row['OrderNo'];?>]" value="checked"></td> <td width="33"> </td> <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td> <td width="61" align="center"><?php echo $row['Orderdate'];?></td> <td width="230" align="Left"><?php echo $row['Custname'];?></td> <td width="172"><input type="text" class="order1Form1" name="tn" value="" /></td> <td width="56" align="right"><?php echo $row['Amount'];?></td> <td width="21"> </td> <td width="136" align="center"><?php echo $row['Shippingmet'];?></td> </tr> <? } ?> </table> <!-- data finish --> <!-- --> <div id="btn"> <input type="submit" value="Process"> <div id="btnSpace"> <!-- --> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btn finish --> <div class="clr"> <!-- --> </div> <!-- data content finish --> <!-- data btm start --> <div id="containerBg3"> <div class="padTop1"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data btm finish --> <!-- btm start --> <div id="containerBg1"> <div class="padTop15"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div id="container"> <div id="line"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btm finish --> </form> process.php <?php include('adminconnect.php'); $tbl1 = 'admin'; foreach($_POST['order'] as $orderno => $dmy){ $sql = "UPDATE $tbl1 SET Ordercompleted = 1 WHERE OrderNo= '{$orderno}'"; mysql_query($sql) or die("Failed on order {$orderno}"); } ?>
  9. LOL Cheers!! that was driving me mental What im trying to do now is put a textbox within the Tracking number field so i can fill in the tracking number for each record displayed. How can i do that?
  10. I want my sql within my php to show all records where the orderscompleted field is "0" my code is: <form action = "processed.php" method="post"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data include('adminconnect.php'); $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Ordercompleted = "0" while( $row = mysql_fetch_array($sql) ) { // loop through and display ?> <tr align="left"> <td width="33"> </td> <td><input type = "checkbox" name="order[<?php echo $row['OrderNo'];?>]" value="checked"></td> <td width="33"> </td> <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td> <td width="61" align="center"><?php echo $row['Orderdate'];?></td> <td width="230" align="Left"><?php echo $row['Custname'];?></td> <td width="170" align="center"><?php echo $row['Trackno'];?></td> <td width="56" align="right"><?php echo $row['Amount'];?></td> <td width="21"> </td> <td width="136" align="center"><?php echo $row['Shippingmet'];?></td> </tr> <? } ?> </table> <!-- data finish --> <!-- --> <div id="btn"> <input type="submit" value="Process"> <div id="btnSpace"> <!-- --> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btn finish --> <div class="clr"> <!-- --> </div> <!-- data content finish --> <!-- data btm start --> <div id="containerBg3"> <div class="padTop1"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data btm finish --> <!-- btm start --> <div id="containerBg1"> <div class="padTop15"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div id="container"> <div id="line"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btm finish --> </form>
  11. One quick question What does the $orderno => $dmy refer to?
  12. GREAT SPOT!!!! Thats working now. Thanks a million for all your help. I'll put the code back piece by piece into the original Thanks again for your help Cheers
  13. LOL..........Its been driving me mad all weekend!!! getting the error Failed on order 7112
  14. This still doesnt post a 1 into the table?? My SQL for the table is -- ---------------------------- -- Table structure for admin -- ---------------------------- CREATE TABLE `admin` ( `OrderNo` decimal(8,0) default NULL, `Orderdate` date default NULL, `Custname` char(10) collate latin1_general_ci default NULL, `Dispatchdate` date default NULL, `Trackno` decimal(8,0) default NULL, `Amount` decimal(5,0) default NULL, `Shippingmet` char(255) collate latin1_general_ci default NULL, `Ordercompleted` decimal(10,0) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- ---------------------------- -- Records -- ---------------------------- INSERT INTO `admin` VALUES ('34556', '2008-01-20', 'rob', '2008-01-21', '34112', '45', 'air', '1'); INSERT INTO `admin` VALUES ('41123', '2008-01-20', 'Mike', '2008-01-23', '99008', '45', 'Air', '1'); INSERT INTO `admin` VALUES ('676767', '2008-01-22', 'Gerry', '2008-02-01', '99999999', '13', 'hffhf', '0'); INSERT INTO `admin` VALUES ('5656', '2011-01-23', 'HHHH', '2008-02-07', '98989', '32', '333', '1'); INSERT INTO `admin` VALUES ('9695959', '2008-01-23', 'TEST', '2008-01-31', '56778', '500', 'Normal', '0'); INSERT INTO `admin` VALUES ('56566556', '2008-01-23', 'iurituritu', '2008-01-24', '989898', '33', 'test', '0'); INSERT INTO `admin` VALUES ('77777', '2008-01-24', 'jkjkjkj', '2008-02-09', '99999', '87', 'hjhj', '1'); INSERT INTO `admin` VALUES ('99999999', '2008-01-25', 'MMMMM', '2008-01-26', '6776767', '8554', 'Air', '0'); INSERT INTO `admin` VALUES ('7112', '2008-01-28', 'ppppp', '2008-02-15', '667', '78', 'air', '0');
  15. Yes this goes to the processed.php page and displays Array ( [order] => Array ( [7112] => checked ) )
  16. I can confirm that by clicking the submit button labeled process it does not got the the processed.php page
  17. My submit button looks like this <input type="submit" value="Process"> Should this include a post too?? My new.php looks like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>ADMIN PAGE|order</title> <link href="../Admin_files/admin.css" rel="stylesheet" type="text/css" /> <script type="text/JavaScript" src="../Admin_files/wrapper.js"></script> </head> <body> <div id="Box"> <div id="logoBox"><a href="http://www.btrax.com/" target="_blank"><img src="../Admin_files/logo.gif" width="51" height="125" border="0" /></a></div> <div id="contentBox"> <form action = "processed.php" method="post"> <!-- logo start --> <div id="container"> <div class="padTop28"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- logo finish --> <!-- menu start --> <div id="container"> <div id="menu1"> <div id="menu_on"><!-- --></div> <div id="menu_text_on"><a href="../admin_files/new.php" class="black_on">Order</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="../sales/sales.php" class="black">Sales</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="../item/list.php" class="black">Edit item</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="../shipping/current.php" class="black">Postage fee</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="../shipping/current.php" class="black">Add User</a></div> <div id="menu_space1"><!-- --></div> <div id="menu_off"><!-- --></div> <div id="menu_text_off"><a href="../shipping/current.php" class="black">Add Product</a></div> <div id="menu_space1"><!-- --></div> </div> <div class="clr"><!-- --></div> <div class="clr"> <!-- --> </div> <div class="padTop5"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div id="dotted"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div class="padTop5"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div id="menu2"> <div id="menu_hide"> <!-- --> </div> <div id="menu_text_on"><a href="../admin_files/new.php" class="black_on">New orders</a></div> <div id="menu_space2"> <!-- --> </div> <div id="menu_text_off"><a href="../admin_files/Unprocessed.php" class="black">Unprocessed orders</a></div> <div id="menu_space2"> <!-- --> </div> <div id="menu_text_off"><a href="../admin_files/completed.php" class="black">Completed orders</a></div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop38"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- menu finish --> <!-- top start --> <div id="container"> <div id="line"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div id="containerBg1"> <div class="padTop15"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- top finish --> <!-- data title start --> <div id="containerBg2"> <div class="padTop2"> <!-- --> </div> <div class="clr"> <!-- --> </div> <div class="titleBox"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td width="64"> </td> <td width="33"> </td> <td width="86"><a href="#">order no.</a></td> <td width="63"><a href="#">date</a></td> <td width="240"><a href="#">customer name</a></td> <td width="172"><a href="#">e-mail</a></td> <td width="64" align="right"><a href="#">amount</a></td> <td width="23"> </td> <td width="138"><a href="#">shipping method</a></td> </tr> </table> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data title finish --> <!-- 1px space start --> <div id="containerBg1"> <div class="padTop1"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- 1px space finish --> <!-- data top start --> <div id="containerBg3"> <div class="padTop1"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data top finish --> <!-- data content start --> <div id="containerBg4"> <!-- data start --> <div class="padTop11"> <!-- --> </div> <div class="clr"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data include('adminconnect.php'); $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = DATE_FORMAT(now(),'%y/%m/%d')"); while( $row = mysql_fetch_array($sql) ) { // loop through and display ?> <tr align="left"> <td width="33"> </td> <td><input type = "checkbox" name="order[<?php echo $row['OrderNo'];?>]" value="checked"></td> <td width="33"> </td> <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td> <td width="61" align="center"><?php echo $row['Orderdate'];?></td> <td width="230" align="Left"><?php echo $row['Custname'];?></td> <td width="170" align="center"><?php echo $row['Trackno'];?></td> <td width="56" align="right"><?php echo $row['Amount'];?></td> <td width="21"> </td> <td width="136" align="center"><?php echo $row['Shippingmet'];?></td> </tr> <? } ?> </table> <!-- data finish --> <!-- --> </div> <div id="btn"> <div id="btnL"><img src="../Admin_files/btn_delete.gif" alt="delete" width="73" height="23" /></div> <div id="btnSpace"> <!-- --> <input type="submit" value="Process"> </div> <div id="btnR"><a href="processed.php"><img src="../Admin_files/btn_process.gif" alt="process" width="73" height="23" border="0" /></a></div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btn finish --> </div> <div class="clr"> <!-- --> </div> <!-- data content finish --> <!-- data btm start --> <div id="containerBg3"> <div class="padTop1"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <!-- data btm finish --> <!-- btm start --> <div id="containerBg1"> <div class="padTop15"> <!-- --> </div> <div class="clr"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div id="container"> <div id="line"> <!-- --> </div> </div> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btm finish --> </form> </div> </div> </body> </html>
  18. As i mentioned before it doesnt goto the processed.php page just remains at the new.php but the browser changes to: http://localhost/Admin_files/new.php?order%5B7112%5D=checked
  19. Just tried that but it doesnt update the field
  20. That would make more sense because i could have more than one record that needs to be checked!! Should I changed my SQL to something like : update admin set Ordercompleted = "1" where OrderNo = $row['OrderNo']; Not too sure how to word the SQL?
  21. The records i need are generated by the php code along with the checkbox. There isnt a need for input fields in this case
  22. I'll cut down my form <form> <form action = "processed.php" method="post"> <!-- --> </div> <div class="titleBox"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <tr align="left"> <td width="64"> </td> <td width="33"> </td> <td width="86"><a href="#">order no.</a></td> <td width="63"><a href="#">date</a></td> <td width="240"><a href="#">customer name</a></td> <td width="172"><a href="#">e-mail</a></td> <td width="64" align="right"><a href="#">amount</a></td> <td width="23"> </td> <td width="138"><a href="#">shipping method</a></td> </tr> </table> </div> <div class="clr"> <!-- --> <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data include('adminconnect.php'); $sql = mysql_query("SELECT OrderNo, Orderdate, Custname, Amount, Shippingmet FROM admin WHERE Orderdate = DATE_FORMAT(now(),'%y/%m/%d')"); while( $row = mysql_fetch_array($sql) ) { // loop through and display ?> <tr align="left"> <td width="33"> </td> <td><input type = "checkbox" name="checkbox" value="checked"></td> <td width="33"> </td> <td width="82"><a href="javascript:openWindow('popup_detail.html', 'NewWindow', 615, 600)" class="black"><?php echo $row['OrderNo'];?></a></td> <td width="61" align="center"><?php echo $row['Orderdate'];?></td> <td width="230" align="Left"><?php echo $row['Custname'];?></td> <td width="170" align="center"><?php echo $row['Trackno'];?></td> <td width="56" align="right"><?php echo $row['Amount'];?></td> <td width="21"> </td> <td width="136" align="center"><?php echo $row['Shippingmet'];?></td> </tr> <? } ?> </table> <!-- data finish --> <!-- --> </div> <div id="btn"> <div id="btnL"><img src="../Admin_files/btn_delete.gif" alt="delete" width="73" height="23" /></div> <div id="btnSpace"> <!-- --> <input type="submit" value="Process"> </form>
  23. The adminconnect file is <? $host="Localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="admin"; // Database name //Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); ?> What I want to achive with this code is when the checkbox is checked and the proceed button is pressed a 1 will appear in the relevent "Orderscompleted" field
×
×
  • 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.