mikebyrne Posted January 23, 2008 Share Posted January 23, 2008 I would like my admin section to process orders which are selected by the corresponding checkbox ie when the user presses the proceed button the loop starts then need a 1 to appear in my "Ordercompleted" field The code I have: <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"> </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> </div> <div id="btnR"><a href="unshipped.php"><img src="../Admin_files/btn_process.gif" alt="process" width="73" height="23" border="0" /></a></div> <div class="clr"> Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/ Share on other sites More sharing options...
adam291086 Posted January 23, 2008 Share Posted January 23, 2008 You shouldn't start multiple threads. Just ask the next question in the same threaded. Change <td> <input type = "checkbox" name="checkbox"> </td> to <td> <input type = "checkbox" name="checkbox" value="checked"> </td> Then where ever you send the form too just check the value of checkbox i.e <?php $process=$_POST['checkbox'] if($process =="checked") { //update database here with the 1 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447016 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 At the moment my form doesnt go anywhere it just loads the table. Would I create a page called processed.php and do this: $tbl1 = 'admn' <?php $process=$_POST['checkbox'] if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercomplete)VALUES(1)"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447025 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 I have the following code $tbl1 = 'admn' <?php $process=$_POST['checkbox'] if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercomplete)VALUES(1)"; } ?> but im getting an error Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\Admin_files\processed.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447036 Share on other sites More sharing options...
adam291086 Posted January 23, 2008 Share Posted January 23, 2008 should be $tbl1 = 'admn' <?php $process=$_POST['checkbox']; if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercomplete)VALUES(1)"; } ?> and yes make the form submit and have a processing page. Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447037 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 All that seems to do is print out include('adminconnect.php'); $tbl1 = 'admn' Ive changed orderscomplted too include('adminconnect.php'); $tbl1 = 'admn' <?php $process=$_POST['checkbox']; if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercompleted)VALUES(1)"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447048 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 I changed that to: <?php include('adminconnect.php'); $tbl1 = 'admn' $process=$_POST['checkbox']; if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercompleted)VALUES(1)"; } ?> Getting the error Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\Admin_files\processed.php on line 6 Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447053 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 I presume an unexpected T_VARIABLE means it cant find the varible?? Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447072 Share on other sites More sharing options...
mikebyrne Posted January 23, 2008 Author Share Posted January 23, 2008 I have changed the code to <?php include('adminconnect.php'); $process=$_POST['checkbox']; if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercompleted)VALUES(1)"; } ?> The error is gone but it doesn't do anything! ie alter the database Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447079 Share on other sites More sharing options...
revraz Posted January 23, 2008 Share Posted January 23, 2008 That's because you removed the table name variable $tbl1 = 'admn' you forgot a semi colon there $tbl1 = 'admn'; Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447086 Share on other sites More sharing options...
mikebyrne Posted January 24, 2008 Author Share Posted January 24, 2008 The code is now <?php include('adminconnect.php'); $tbl1 = 'admn'; $process=$_POST['checkbox']; if($process =="checked") { $sql2="INSERT INTO $tbl1(Ordercompleted)VALUES(1)"; } ?> It still doesnt post a 1 in the ordercompleted field in the admin database The structure of admin looks like this -- ---------------------------- -- 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', '0'); Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447673 Share on other sites More sharing options...
mikebyrne Posted January 24, 2008 Author Share Posted January 24, 2008 How could i check If $process is actually running (holding a varible)?? Quote Link to comment https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447714 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.