|
|
|
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource |
|
|
|
|
|
|
|
<body>
<?php
$host = "localhost";
$user = "root";
$password = "2533";
$dbname = "report_pruksa";
mysql_connect($host,$user,$password)or die ("conncet Host disable");
mysql_select_db($dbname)or die("die");
function setthai(){
mysql_query("SET character_set_results=utf8");
mysql_query("SET collation_connection=utf8_general_ci");
mysql_query("SET NAMES 'thai'");
}
setthai();
$sqla = "select count(aid) As NumberOfCustomers1 where cus_family_income ='40,001-50,000 bath'";
$sql1 = mysql_query($sql);
$sqlb = "select count(aid) As NumberOfCustomers2 where cus_family_income ='50,001-60,000 bath'";
$sql2 = mysql_query($sql);
$sqlc = "select count(aid) As NumberOfCustomers3 where cus_family_income ='60,001-70,000 bath'";
$sql3 = mysql_query($sql);
$sqld = "select count(aid) As NumberOfCustomers3 FROM customer";
$sql4 =mysql_query($sql);
?>
<table width="680" border="1">
<tr>
<td colspan="3"><div align="center">Salary Of Customer</div></td>
</tr>
<tr>
<td><div align = "center">Salary</div></td>
<td><div align = "center">Number</div></td>
<td><div align = "center">Percen</div></td>
</tr>
<?php
while($row1 = mysql_fetch_array($sql1)){
$sum2 = $row1['NumberOfCustomers1'];
}
while($row2 = mysql_fetch_array($sql2)){
$sum2 = $row2['NumberOfCustomers2'];
}
while($row3 = mysql_fetch_array($sql3)){
$sum3 = $row3['NumberOfCustomers3'];
}
while($row4 = mysql_fetch_array($sql4)){
$sum4 = $row4['NumberOfCustomers4'];
$all = $row4['NumberOfCustomers4'];
}
$a=array($sum1,$sum2,$sum3,$sum4);
for($i=0;$i<=4;$i++)
{
$percent[$i] = ($a[$i]/$all)*100;
if($i==0)
{
echo"<tr>";
echo"<td><div align=center>40,001-50,000 bath</div></td>";
echo"<td><div align=center>".$a[$i]."</div></td>";
echo"<td><div align=center>".$percent[$i]."% </div></td>";
echo"</tr>";
}
elseif($i==1)
{
echo"<tr>";
echo"<td><div align=center>50,001-60,000 bath</div></td>";
echo"<td><div align=center>".$a[$i]."</div></td>";
echo"<td><div align=center>".$percent[$i]."% </div></td>";
echo"</tr>";
}
elseif($i==2)
{
echo"<tr>";
echo"<td><div align=center>70,001-80,000 bath</div></td>";
echo"<td><div align=center>".$a[$i]."</div></td>";
echo"<td><div align=center>".$percent[$i]."% </div></td>";
echo"</tr>";
}
elseif($i==3)
{
echo"<tr>";
echo"<td><div align=center>Count</div></td>";
echo"<td><div align=center>".$a[$i]."</div></td>";
echo"<td><div align=center>".$percent[$i]."% </div></td>";
echo"</tr>";
}
}
mysql_close();
?>
</table>
</body>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-06-05 15:40:04 |
By :
kanomwarn |
View :
855 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยทีครับ
|
|
|
|
|
Date :
2011-06-05 15:41:17 |
By :
kanomwarn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$sqla = "select count(aid) As NumberOfCustomers1 where cus_family_income ='40,001-50,000 bath'";
$sql1 = mysql_query($sqla); //<--- $sqla
$sqlb = "select count(aid) As NumberOfCustomers2 where cus_family_income ='50,001-60,000 bath'";
$sql2 = mysql_query($sqlb); //<--- $sqlb
$sqlc = "select count(aid) As NumberOfCustomers3 where cus_family_income ='60,001-70,000 bath'";
$sql3 = mysql_query($sqlc); //<--- $sqlc
$sqld = "select count(aid) As NumberOfCustomers3 FROM customer";
$sql4 =mysql_query($sqld); //<--- $sqld
|
|
|
|
|
Date :
2011-06-06 15:35:02 |
By :
ก้องจังงัง |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|