Thank you for your advice, bradgrafelman. I have 41,000 records in my database & I hope thats not too big. I appreciate your advice.
Hello herve, this code gives me an error message. The message is :-
Warning: mysql_result(): area_1 not found in MySQL result index 3 in /home/dgrgroup/public_html/query_results.php on line 65
Warning: mysql_result(): address not found in MySQL result index 3 in /home/dgrgroup/public_html/query_results.php on line 66
Warning: mysql_result(): price not found in MySQL result index 3 in /home/dgrgroup/public_html/query_results.php on line 67
Warning: mysql_result(): secret_formula not found in MySQL result index 3 in /home/dgrgroup/public_html/query_results.php on line 68
What am I doing wrong here? My full code is listed below.
Thanks for your reply, gardnc. I have not tried this yet because I don't know where to implement this code(I don't understand the logic of this code). Could you show me how to implement this code? I appreciate your guidance.
Warm Regards to all of you.
<head>
<title>Untitled Document</title>
</head>
<body>
<?php
$username="abc123";
$password="abc123";
$database="abc123";
$host="localhost";
mysql_connect ("$host","$username","$password");
mysql_select_db($database) or die( "Where's the database man?");
$drop_down_box_1 = $_POST['drop_down_box_1'];
$drop_down_box_2 = $_POST['drop_down_box_2'];
$Text_Box_1 = $_POST['Text_Box_1'];
$Text_Box_2 = $_POST['Text_Box_2'];
$Text_Box_3 = $_POST['Text_Box_3'];
$Text_Box_4 = $_POST['Text_Box_4'];
$Text_Box_5 = $_POST['Text_Box_5'];
$Text_Box_6 = $_POST['Text_Box_6'];
$Text_Box_7 = $_POST['Text_Box_7'];
$Text_Box_8 = $_POST['Text_Box_8'];
$submit2 = $_POST['submit2'];
if ($Text_Box_1 == '') $Text_Box_1 = '0x0x0x0';
if ($Text_Box_2 == '') $Text_Box_2 = '0x0x0x0';
if ($Text_Box_3 == '') $Text_Box_3 = '0x0x0x0';
if ($Text_Box_4 == '') $Text_Box_4 = '0x0x0x0';
if ($Text_Box_5 == '') $Text_Box_5 = '0x0x0x0';
if ($Text_Box_6 == '') $Text_Box_6 = '0x0x0x0';
if ($Text_Box_7 == '') $Text_Box_7 = '0x0x0x0';
if ($Text_Box_8 == '') $Text_Box_8 = '0x0x0x0';
switch($_POST['R1'])
{
case 'and':
$query="SELECT SUM((price*3))/COUNT(*) AS mean FROM average_income WHERE (area_1 like '%$drop_down_box_1%') AND (area_1 like '%$drop_down_box_2%')";
break;
case 'or':
$query="SELECT SUM((price*3))/COUNT(*) AS mean FROM average_income WHERE (area_1 like '%$drop_down_box_1%') OR (area_1 like '%$drop_down_box_2%')";
break;
default:
$query="SELECT id, area_1, address, price, price*3 AS secret_formula FROM average_income WHERE (area_1 = '$drop_down_box_1')";
}
if(isset($submit2))
{
$query="SELECT SUM((price*3))/COUNT(*) AS mean FROM average_income WHERE (address like '%$Text_Box_1%') OR (address like '%$Text_Box_2%') OR (address like '%$Text_Box_3%') OR (address like '%$Text_Box_4%') OR (address like '%$Text_Box_5%') OR (address like '%$Text_Box_6%') OR (address like '%$Text_Box_7%') OR (address like '%$Text_Box_8%')";
}
echo $query;
$result=mysql_query($query);
$num=mysql_numrows($result);
?>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><strong><font size="3" face="Arial, Helvetica, sans-serif">General Location</font></strong></th>
<th><strong><font size="3" face="Arial, Helvetica, sans-serif">Full Add</font></strong></th>
<th><strong><font size="3" face="Arial, Helvetica, sans-serif">Price(Ringgit Malaysia)</font></strong></th>
<th><strong><font size="3" face="Arial, Helvetica, sans-serif">Secret Formula</font></strong></th>
</tr>
<?php
$i=0;
while ($i < $num) {
$area_1 = mysql_result($result,$i,"area_1");
$address = mysql_result($result,$i,"address");
$price = mysql_result($result,$i,"price");
$secret_formula = mysql_result($result,$i,"secret_formula");
?>
<tr>
<td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="70"><font size="2" face="Arial, Helvetica, sans-serif"><? echo "$area_1"; ?></font></td>
<td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="500"><font size="2" face="Arial, Helvetica, sans-serif"><? echo "$address"; ?></font></td>
<td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="90"><font size="2" face="Arial, Helvetica, sans-serif"><? echo "$price"; ?></font></td>
<td style="border-style: solid; border-width: 1" bgcolor="#CCFFFF" align="left" width="90"><font size="2" face="Arial, Helvetica, sans-serif"><? echo "$secret_formula"; ?></font></td>
</tr>
<?php
++$i;
}
echo "</table>";
?>
</body>
</html>