Jump to content

[SOLVED] First row from an array


gerkintrigg

Recommended Posts

Is my math wrong with this?

 

<?php 
include 'db.php';
$i=0;
$no_of_rows=mysql_result(mysql_query("SELECT COUNT(*) AS RECORDS FROM schedule
WHERE '$week_start2'
between start_date and end_date;"),0);
$pquery="SELECT cost, sup_percent 
FROM schedule, rate
WHERE schedule.rate_id = rate.rate_id
and '$week_start2'
between start_date and end_date;";
$pq=mysql_query($pquery);
while ($pr=mysql_fetch_array($pq)){
$i++;
if ($i==1){
	$price=$pr['cost'];
}
else{
	$percentage=($price/100)*$pr['cost'];
}
}
if ($no_of_rows==2){
$price=$price+$percentage;
}

echo $price;
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/44028-solved-first-row-from-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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