Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Posts posted by mikebyrne

  1. At present my sales figure report just shows all the sales per day. I would like it only to display the days of only the current month and also diplay the month/year on the title of the table.

     

    Is there PHP code that will do this on the fly for me as opposed to changing the hard code each month?

     

    My code currently is:

     

    <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">
    <?php
    
    include('adminconnect.php');
    $sql = mysql_query("SELECT * 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>
    
    
    <?php
    }
    ?>
    </table>	
    
    
    
    
    <!-- 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>
    
    <!-- btm finish -->
    
    </form>
    

     

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

     

  4. 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>
    

  5. 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>
    

     

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

     

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

     

  8. 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;

     

    -- ----------------------------

     

     

×
×
  • 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.