Jump to content

diginamics

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Posts posted by diginamics

  1. Please check the img link and you will understand

     

    Untitled-1.jpg

     

    for ($index = 1; $index <= $numdays; $index++) {
    
    $users="SELECT invoice_date, DAY(invoice_date) as invoiceday, sum(total_amount) as fullamount from invoices 
    WHERE MONTH(invoice_date)='".$month."' AND YEAR(invoice_date)='".$year."' GROUP BY invoiceday";
    $res=mysql_query($users);
    $row=mysql_num_rows($res);
    
    
    
    while($fetch=mysql_fetch_array($res)){
    
    
    echo "<tr id='". ( ( $j %2 == 0 ) ? 'row3' : 'row4' ) . "'>";
    
    $explodedate=explode("-",$fetch['invoice_date']);
    $days=$explodedate[2];
    $month1=$explodedate[1];
    $year1=$explodedate[0];
    
    $dates=date("jS", strtotime($fetch['invoice_date']));
    
    
    echo "<td style='text-align:left;padding-left:12px'>".$index."</td>";
    if($index==$dates){
    
    echo "<td style='text-align:right;padding-right:12px'>".$fetch['fullamount']."</td>";
    
    }else{		
    
    echo "<td style='text-align:right;padding-right:12px'>--</td>";
    
    }
    
    echo "</tr>";
    }
    
    
    
    }
    
    
    $total="SELECT SUM(total_amount) as fulltotal from invoices where MONTH(invoice_date)='".$month1."' AND YEAR(invoice_date)='".$year1."';";
    
    $totres=mysql_query($total);
    $totfetch=mysql_fetch_assoc($totres);
    if($totfetch['fulltotal']==""){
    echo "<tr><td>NOTHING FOUND</td></tr>";
    }else{
    ECHO "<TR>";
    echo "<td style='color:#BD0000;padding-left:12px;border:1px solid #ccc;width:20%;height:40px;text-align:left'>TOTAL AMOUNT FOR ".$displaydate."</td>";
    echo "<td style='color:#BD0000;border:1px solid #ccc;width:20%;height:40px;text-align:right;padding-right:12px'>".$totfetch['fulltotal']."</TD></TR>";
    
    }
    echo "</table>";
    

  2. Have a look at this image

    2.jpg

    Here is the part of the form code that makes them into arrays

    $sql="select * from products";
    $res=mysql_query($sql);
       
    WHILE($fetch=mysql_fetch_assoc($res)){
    echo "<td><input type=hidden name='desBox[]' id='desBox[]' value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td>
    <td><input type=text id=quantBox[]  maxlength=6 name=quantBox[]></td>
    <td><input type=text maxlength=6 id=teethBox[] name=teethBox[]></td>";
    echo "</tr>";}
    

     

  3. The first query inserts values in table job_oder

    The second query is supposed to insert array data into table 'orderprod'

     

    sql="insert into job_order(order_num,order_date,order_customer_id,	order_remarks)	values(".$_GET['id'].",NOW(),".$_POST['companyBox'].",'".$_POST['remarkBox']."');";	
    $res=mysql_query($sql); 

     

    AND THE SECOND ONE

     

    $order="INSERT INTO orderprod (order_num,prod_id,order_amount,teeth_amount) VALUES	('$_GET[id]','$value','$value','$value');";	$orderres=mysql_query($order) or die(mysql_error());
    

     

    and you are right this ($key.' => '.trim(strip_tags($value)); ) does not do anything. I had removed it ealier

     

     

  4. First page adds a new job number, then the order page loaded with the job number id as a get id. Basically there is a while loop in the order page which shows products/services client can order and he chooses what he requires 'one or eight services' (8 in total) and some other variables like date of order and client name etc. Here is the order item code

     

    The first sql statement executes fine, but in the second sql query nothing happens

     

    $sql="insert into job_order(order_num,order_date,order_customer_id,	order_remarks)	values(".$_GET['id'].",NOW(),".$_POST['companyBox'].",'".$_POST['remarkBox']."');";	$res=mysql_query($sql); 	$id=mysql_insert_id();  	foreach($_POST as $key => $value) {          if(!empty($value)) {           $key.' => '.trim(strip_tags($value));            $order="INSERT INTO orderprod (order_num,prod_id,order_amount,teeth_amount) VALUES	('$_GET[id]','$value','$value','$value');";	$orderres=mysql_query($order) or die(mysql_error());	}	}?>$sql="insert into job_order(order_num,order_date,order_customer_id,
    order_remarks)
    values(".$_GET['id'].",NOW(),".$_POST['companyBox'].",'".$_POST['remarkBox']."');";
    $res=mysql_query($sql);
    
    $id=mysql_insert_id();
    
    
    foreach($_POST as $key => $value) {
    
    
            if(!empty($value)) { 
    
             $key.' => '.trim(strip_tags($value));  
         
             $order="INSERT INTO orderprod (order_num,prod_id,order_amount,teeth_amount) VALUES
    ('$_GET[id]','$value','$value','$value');";
    $orderres=mysql_query($order) or die(mysql_error());
    }
    }
    ?>
    
    

     

    =============

     

    This is the formI have removed parts which are irrelevant. Please note that dateBox and companyBox are not required to be looping as they are only for first table,

     

     

    echo "<form action=".$config_basedir."./vieworder.php?id=".$_GET['id']."  name=form1 method=post>";?><table><tr><td><h4>JOB ORDER</H4></TD><TD></TD></TR><TR><TD>ORDER NUMBER</TD><TD><?PHP ECHO $_GET['id'] ?></td></tr><tr><td>ORDER DATE</td><td><input type=text name=dateBox></td></tr> <tr><td>COMPANY NAME</td><td><?PHP$sql="select * from customers";$res=mysql_query($sql);echo "<select name=companyBox><option value=''>Please select</option>";WHILE($fetch=mysql_fetch_assoc($res)){ echo "<option value='".$fetch['id']."'>".$fetch['cust_name']."</option>";}	echo "</select>";	echo "</td></tr>";	?>   </table> <table><tr><th>ITEM</th><th>QUANTITY</th><th>N0. of Teeths</th></tr><tr><?PHP$sql="select * from products";$res=mysql_query($sql); WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=text name=desBox value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td><td><input type=text name=quantBox></td><td><input type=text name=teethBox></td>";echo "</tr>";}echo "</table>";?>echo "<form action=".$config_basedir."./vieworder.php?id=".$_GET['id']."  name=form1 method=post>";
    ?>
    <table>
    <tr>
    <td><h4>JOB ORDER</H4></TD><TD></TD>
    </TR>
    <TR>
    <TD>ORDER NUMBER</TD><TD><?PHP ECHO $_GET['id'] ?></td>
    </tr>
    <tr>
    <td>ORDER DATE</td><td><input type=text name=dateBox></td>
    </tr>
    
    <tr>
    <td>COMPANY NAME</td><td>
    <?PHP
    $sql="select * from customers";
    $res=mysql_query($sql);
    echo "<select name=companyBox><option value=''>Please select</option>";
    WHILE($fetch=mysql_fetch_assoc($res)){
    
    echo "<option value='".$fetch['id']."'>".$fetch['cust_name']."</option>";}
    echo "</select>";
    echo "</td></tr>";
    ?>
    
    
    
    </table>
    
    <table>
    <tr>
    <th>ITEM</th><th>QUANTITY</th><th>N0. of Teeths</th>
    </tr>
    <tr>
    <?PHP
    $sql="select * from products";
    $res=mysql_query($sql);
    
    WHILE($fetch=mysql_fetch_assoc($res)){
    
    echo "<td><input type=text name=desBox value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td>
    <td><input type=text name=quantBox></td>
    <td><input type=text name=teethBox></td>";
    echo "</tr>";}
    echo "</table>";
    ?>
    

     

     

    HERE IS THE IMAGE showing the populated services.

    http://dubads.com/images/order.jpg

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