Jump to content

Recommended Posts

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">

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/
Share on other sites

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
}
?>

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447016
Share on other sites

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)";
}

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447025
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447036
Share on other sites

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)";
}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447048
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447053
Share on other sites

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');

 

Link to comment
https://forums.phpfreaks.com/topic/87389-processing-an-order/#findComment-447673
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.