Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Everything posted by mikebyrne

  1. Still cant get it to post the results underneath each other!!
  2. yeah i know that my code is <tr align="left"> <td width="87" align="center"><?php echo $row['Date'];?></td> <td width="43" align="Left"><?php echo $row['Total Orders'];?></td> <td width="118" align="center"><?php echo $row['Revenue'];?></td> </tr> It goes through the loop but puts the results next to each other as opposed to on new row
  3. How do i get the figures in line with my headings and also appear row by row as opposed to next to each other?
  4. getting the error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\Admin_files\Sales.php on line 152 line 152 refers above the first ?>
  5. Like <?php include('adminconnect.php'); $sql = mysql_query("SELECT Date, Total Orders, Revenue FROM sales "); while( $row = mysql_fetch_array($sql) ) { ?> <tr align="left"> <td width="87" align="center"><?php echo $row['Date'];?></td> <td width="43" align="Left"><?php echo $row['Total Orders'];?></td> <td width="118" align="center"><?php echo $row['Revenue'];?></td> </tr> <? } ?> </table>
  6. I want to put my sales figures into the table below. The table name is Sales which is linked by using require_once('adminconnect.php'); $tbl2 = 'sales'; The fields in the table are Date, Total Orders & Revenue. What would the php be to place this into a table? <form> <!-- 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="33"> </td> <td width="87"><a href="#">date</a></td> <td width="43" align="right"><a href="#">orders</a></td> <td width="118" align="right"><a href="#">revenue</a></td> <td width="569"> </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 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>
  7. Thanks everyone for all the help! Got it working with the following code <?php require_once('adminconnect.php'); $tbl1 = 'admin'; if($_SERVER['REQUEST_METHOD'] == 'POST'){ //Mark Completed Orders if(is_array($_POST['order'])){ foreach(array_keys($_POST['order']) as $orderno){ if(!is_numeric($orderno)) continue; $sql = "UPDATE `{$tbl1}` SET `Ordercompleted` = 1 WHERE `OrderNo` = '{$orderno}'"; mysql_query($sql) or die("Failed to mark order #{$orderno} as completed"); } } //Update Tracking Numbers if(is_array($_POST['trackno'])){ foreach($_POST['trackno'] as $orderno => $text){ if(!is_numeric($orderno)) continue; $text = mysql_real_escape_string(trim($text)); $sql = "UPDATE `{$tbl1}` SET `Trackno` = '{$text}' WHERE `OrderNo` = '{$orderno}'"; mysql_query($sql) or die("Failed to add tracking number to order #{$orderno}"); } } header('Location: '.$_SERVER['PHP_SELF']); exit; } ?> <!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"> <!-- 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/start.php" class="black">New orders</a></div> <div id="menu_space2"> <!-- --> </div> <div id="menu_text_off"><a href="../admin_files/Unprocessed.php" class="black_on">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="#">Tracking No</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"> <form method="post"> <table width="850" border="0" cellspacing="0" cellpadding="0"> <?php // let's get some data $sql = mysql_query("SELECT * FROM `{$tbl1}` 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'];?>]"></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" name="trackno[<?php echo $row['OrderNo'];?>]" value="<?php echo htmlspecialchars($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> <?php } ?> </table> <!-- data finish --> <!-- --> <div id="btn"> <input type="submit" value="Process"> </div> </form> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btn finish --> <div class="clr"> <!-- --> </div> <!-- data content finish --> </form> <!-- 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> <!-- btm finish --> </div> </div> </body> </html>
  8. I updated the code but it still just puts 1 in all the Ordercompleted
  9. Ah ok, thanks The only problem left is getting the 1 to post into the Orderscompleted field
  10. That seems to put 0 in all Tracno fields as opposed to the user input
  11. <?php include('adminconnect.php'); function fnGetTrackNum($arrPost) { $arrReturn = array(); foreach ($arrPost as $strKey => $strValue) { if (preg_match("/^trackno_/",$strKey)) { $arrReturn[preg_replace("/^trackno_/","",$strKey)] = $strValue; } } return $arrReturn; } $arrTrackNo = fnGetTrackNum($_POST); foreach($arrTrackNo 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}<BR>mysql Error:".mysql_error()."<BR>Sql:".$sql); } ?>
  12. The form for unprocessed.php 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="172"><input type="text" name="trackno_<?php echo $row['OrderNo'];?>" value="<?php echo htmlspecialchars($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> <div class="clr"> <!-- --> </div> <div class="padTop16"> <!-- --> </div> <div class="clr"> <!-- --> </div> <!-- btn finish --> <div class="clr"> <!-- --> </div> <!-- data content finish --> </form>
  13. The default for the Trackno is Null -- ---------------------------- -- 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; -- ----------------------------
  14. Failed on order 9695959 mysql Error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET Trackno = 'KKKK' WHERE OrderNo= '9695959'' at line 1 Sql:UPDATE SET Trackno = 'KKKK' WHERE OrderNo= '9695959'
  15. No problem you help is REALLY apricated! Getting the error Failed on order 9695959
  16. Getting closer! But getting an error on processed.php Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\Admin_files\processed.php on line 8
  17. Thanks for yuor help but im getting another Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\xampp\htdocs\Admin_files\Unprocessed.php on line 223
  18. This puts the order number into the TrackNo textboxes? I want the textboxes to be blank and whatever the user inputs into the box goes into the Tracno field
  19. <td width="172"><input type="text" name="trackno[]" value="<?php echo $row['OrderNo];?>,<?php echo htmlspecialchars($row['Trackno']);?>" /></td>
  20. Just that I'm getting a error Parse error: syntax error, unexpected T_STRING, expecting ']' in C:\xampp\htdocs\Admin_files\Unprocessed.php on line 223
  21. Is this line correct?? <td width="172"><input type="text" name="trackno[]" value="<?php echo $row['OrderNo];?>,<?php echo htmlspecialchars($row['Trackno']);?>" /></td>
  22. Seems to have fixed the error but doesnt post the trackno figures into the field <?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}"); } ?>
  23. Its there to post the Trackno into the field, how can I adjust this?
×
×
  • 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.