I am working on a project where in I have tables of Invoices, Quotations and many more.
Where I am stuck is here -
I am saving values of quotation in to a table as a n array. Eg :-
If two services are selected then it saves it in this way : Service1, service2 Similarly its quantity and charges are saved in d same way:
Sqty : 1,1
Scharge: 100,300
Now For Invoice, I get the quotation id and service name from POST
$qdetails = mysql_query("SELECT * FROM tbl_quotation WHERE id ='$qid';") or die(mysql_error()); $qdet = mysql_fetch_array( $qdetails ); $pcharge = $qdet['pcharge']; $scharge = $qdet['scharge']; $pqty = $qdet['pqty']; $sqty = $qdet['sqty'];
Then display the output in the following table - tbl_service_info is my table which has all the details of the service
<?php
foreach ($_POST['service'] as $key => $value) {
$query=("select * from tbl_service_info WHERE sname = '$value'");
$result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() );
while($row=mysql_fetch_array($result)){
$product = @$row["sname"];
$prid = @$row["id"];
$sdetails = @$row["details"];
?>
<tr class="item-row">
<td class="item-name"><div class="delete-wpr">
<textarea name="services[]"><?php echo $value ; ?></textarea></div></td>
<td class="description"><textarea><?php echo $sdetails; ?></textarea></td>
<td><textarea class="description"><?php echo $sunit; ?></textarea></td>
<?php }
$scharge1 = explode(",",$scharge);
foreach ($scharge1 as $keysc => $valuesc) { ?>
<td><textarea class="cost" name="scharge[]"> <?php
echo $valuesc;?> </textarea> </td> <?php } ?>
<?php
$sqty1 = explode(",",$sqty);
foreach ($sqty1 as $key2 => $value2) { ?>
<td><textarea class="qty" name="snos[]"><?php echo $value2;?></textarea></td>
<?php } ?>
<td><span class="price"></span></td>
</tr>
<?php } ?>
This is what i get.
http://oi61.tinypic.com/286v30j.jpg
http://oi61.tinypic.com/286v30j.jpg
The Unit Cost and Nos are not looping with the main loop.
Please help. Also correct my question If I have written it the wrong way.
Thanks...