Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Add Multiple Rows in MySQL Php
    primarykey
    data
    text
    <p>i want to plus amount + servicecharges + replacecharges + blockcharges + othercharges</p> <p>but it is not working please help me to fix this issue thanks</p> <pre><code>$sql="SELECT CONCAT(monthdate,' ','(',drivernamefuel,')') as drivernamefuel,sum(amount) + 'servicecharges' + 'replacecharges' + 'blockcharges' + 'othercharges' AS amount,drivernamefuel FROM $tablename where carno='$c' AND monthdate BETWEEN '$a' AND '$b' GROUP BY monthdate"; </code></pre> <p>See ScreenShort File #1: <a href="http://www.koolfree.com/ImageUpload/uploads/1381252318.jpg" rel="nofollow">http://www.koolfree.com/ImageUpload/uploads/1381252318.jpg</a></p> <p>File #2: <a href="http://www.koolfree.com/ImageUpload/uploads/1381228480.jpg" rel="nofollow">http://www.koolfree.com/ImageUpload/uploads/1381228480.jpg</a></p> <p>it is showing these error Warning: Division by zero in indexssds.php on line 51</p> <p>Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in indexssds.php on line 73</p> <p>here is complete code please check my update thanks ...........................</p> <pre><code> &lt;?php include 'config.php'; $link=mysql_connect("$hostname","$username","$password")or die('Could not connect: ' . mysql_error()); mysql_select_db("$dbname",$link); function formatMoney($number, $fractional=false) { if ($fractional) { $number = sprintf('%.2f', $number); } while (true) { $replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number); if ($replaced != $number) { $number = $replaced; } else { break; } } return $number; } $a=$_POST['from']; $b=$_POST['to']; $c=$_POST['to2']; echo " &lt;p align='center' class='style1'&gt;Vehicle No: $c &lt;/p&gt;"; echo "&lt;span align='center' class='style1'&gt;Report For The Period Of $a to $b &lt;/span&gt;"; include 'create.php'; $sql="SELECT CONCAT(monthdate,' ','(',drivernamefuel,')') as drivernamefuel, SUM(ifnull(amount,0) + ifnull(servicecharges,0) + ifnull(replacecharges,0) + ifnull(blockcharges,0) + ifnull(othercharges,0) ) AS amount, drivernamefuel FROM $tablename where carno='$c' AND monthdate BETWEEN '$a' AND '$b' GROUP BY monthdate"; $result = mysql_query($sql); $graphtitle="For The month of $a to $b";//Graph Title $xname="BarChart Report By Vehicle No : $c"; $yname='VALUE';//y-axis name $img_width=900;//image height $img_height=700;//image width $margins=70; $ymargin=6; $count=mysql_affected_rows(); $graph_width=$img_width - $margins * 2; $graph_height=$img_height - $margins * 2; $bar_width=25; $total_bars=$count; $gap= ($graph_width- $total_bars * $bar_width ) / ($total_bars +1); $img=imagecreate($img_width,$img_height); include 'barcolor.php'; imagefilledrectangle($img,0,0,0,0,$bag_color); imageline($img,$margins,$img_height-45,$img_width-20,$img_height-45,$xyline_color); imageline($img,$margins,$ymargin,$margins,$img_height-45,$xyline_color); $maxvalue="select max(monthdate) as amount from $tablename";//Give your field name for Y axis $max=mysql_query($maxvalue); while($inf1= mysql_fetch_array($max)) { $ratio=$graph_height/$inf1[0]; } $horizontal_lines=8; $horizontal_gap=($img_height+20)/$horizontal_lines; for($j=1;$j&lt;=$horizontal_lines;$j++) { $y=($img_height-48) - $horizontal_gap * $j ; //imageline($img,$margins+1,$y,$img_width-20,$y,$hline_color); $v=intval($horizontal_gap * $j /$ratio); imagestring($img,2,$margins-30,$y-5,$v,$values_color); } $i=0; while($inf = mysql_fetch_array($result)) { $x1=($margins+10) + ($gap+5) + $i * ($gap+$bar_width) ; $x2=$x1+$bar_width; $y1=($img_height-46)- ceil($inf[1] * $ratio) ; $y2=($img_height-46); imagestring($img,2,$x1+1,$y1-15,$inf[1],$values_color); imagestring($img,2,$x2-23,$img_height-43,$inf[0],$values_color); imagefilledrectangle($img,$x1,$y1,$x2,$y2,$bar_color); // Draw bar $i++; } imagestring($img,8, ($img_width-$margin)/2, 0, $graphtitle, $txt_color); imagestring($img,5, ($img_width-$margin)/2, $img_height-($ymargin+10), $xname, $txt_color); imagestringup($img,5,10,($img_height-$ymargin)/2, $yname, $txt_color); //header('Content-type: image/png'); imagepng($img, 'barchart.jpg'); echo "&lt;div style='border:1px solid #d8d8d8;width:$img_width'&gt;&lt;img src='barchart.jpg'&gt;&lt;/div&gt;"; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload