hi,
i have a simple php code; it displays selected data from mysql database.
code:
<?php
$span=$_POST['span'];
$blength=$_POST['length'];
$connection = mysql_connect("localhost","root","jp");
mysql_select_db("db1", $connection);
$result = mysql_query ("SELECT bmodel, blength, bspan, bsnowload, bprice FROM
qbay WHERE bspan='$span'", $connection);
print "Model: Length: Span: Load: Price:<br>";
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
foreach ($row as $attribute)
print "{$attribute} ";
print "\n";
}
mysql_close($connection);
?>
output:
Model: Length: Span: Load: Price:
SDFS 7 35 20 9070.38600
SVFS 7 35 23 11251.26400
TDFS 7 35 0 12260.12502
TVFS 7 35 49 15182.74888
i need to do some calculations and attach them to output; so i modified my php code:
<?php
$span=$_POST['span'];
$plength=$_POST['length'];
$numbays=intval($plength/7);
$connection = mysql_connect("localhost","root","jp");
mysql_select_db("db1", $connection);
$result = mysql_query ("SELECT bmodel, blength, bspan, bsnowload, bprice FROM
qbay WHERE bspan='$span'", $connection);
print "Model: Length: Span: Load: Price:<br>";
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
$bmodel=$row['bmodel'];
$blentgh=$row['blength'];
$bspan=$row['bspan'];
$bsnowload=$row['bsnowload'];
$bprice=$row['bprice'];
$minlength=$numbays*$blength;
$minprice=$numbays*$bprice;
$maxlength=($numbays+1)*$blength;
$maxprice=($numbays+1)*$bprice;
print "$bmodel $blength $bspan $bsnowload $bprice $minlength $minprice $maxlength $maxprice";
}
mysql_close($connection);
?>
but for the same input data i got output like this:
Model: Length: Span: Load: Price:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
can you please help me fix this code? i am new to php and i try to make very simple web version of existing windows vb6 application. thanks.
i have a simple php code; it displays selected data from mysql database.
code:
<?php
$span=$_POST['span'];
$blength=$_POST['length'];
$connection = mysql_connect("localhost","root","jp");
mysql_select_db("db1", $connection);
$result = mysql_query ("SELECT bmodel, blength, bspan, bsnowload, bprice FROM
qbay WHERE bspan='$span'", $connection);
print "Model: Length: Span: Load: Price:<br>";
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
foreach ($row as $attribute)
print "{$attribute} ";
print "\n";
}
mysql_close($connection);
?>
output:
Model: Length: Span: Load: Price:
SDFS 7 35 20 9070.38600
SVFS 7 35 23 11251.26400
TDFS 7 35 0 12260.12502
TVFS 7 35 49 15182.74888
i need to do some calculations and attach them to output; so i modified my php code:
<?php
$span=$_POST['span'];
$plength=$_POST['length'];
$numbays=intval($plength/7);
$connection = mysql_connect("localhost","root","jp");
mysql_select_db("db1", $connection);
$result = mysql_query ("SELECT bmodel, blength, bspan, bsnowload, bprice FROM
qbay WHERE bspan='$span'", $connection);
print "Model: Length: Span: Load: Price:<br>";
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
$bmodel=$row['bmodel'];
$blentgh=$row['blength'];
$bspan=$row['bspan'];
$bsnowload=$row['bsnowload'];
$bprice=$row['bprice'];
$minlength=$numbays*$blength;
$minprice=$numbays*$bprice;
$maxlength=($numbays+1)*$blength;
$maxprice=($numbays+1)*$bprice;
print "$bmodel $blength $bspan $bsnowload $bprice $minlength $minprice $maxlength $maxprice";
}
mysql_close($connection);
?>
but for the same input data i got output like this:
Model: Length: Span: Load: Price:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
can you please help me fix this code? i am new to php and i try to make very simple web version of existing windows vb6 application. thanks.