I would like to have a table generated based on whether the condition result1, result2, or result3 is met. Here is what I have but it's not right.
if(($region=all) and ($countries=all)){
$result1 = mysql_query("SELECT * FROM trips WHERE cost>='$price1' AND cost<='$price2'",$db);
}
else if($countries=all){
$result2 = mysql_query("SELECT country FROM trips WHERE region LIKE '$region' AND cost>='$price1' AND cost<='$price2'",$db);
}
else
{
$result3 = mysql_query("SELECT * FROM trips WHERE region LIKE '$region' AND country LIKE '$countries' AND cost>='$price1' AND cost<='$price2'",$db);
}
do
{
echo "<table border=1>\n";
echo "<tr><td>Trip Name</td><td>Region</td><td>Country</td> <td>Description</td><td>Cost</td><td>Duration</td><td>Lodging</td><td>Grade</td></tr>";
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[6], $myrow[7], $myrow[8], $myrow[9]);
echo "</table>\n";
}
while ($myrow = mysql_fetch_row($result1);
do
{
echo "<table border=1>\n";
echo "<tr><td>Trip Name</td><td>Region</td><td>Country</td> <td>Description</td><td>Cost</td><td>Duration</td><td>Lodging</td><td>Grade</td></tr>";
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[6], $myrow[7], $myrow[8], $myrow[9]);
echo "</table>\n";
}
while ($myrow = mysql_fetch_row($result2);
do
{
echo "<table border=1>\n";
echo "<tr><td>Trip Name</td><td>Region</td><td>Country</td> <td>Description</td><td>Cost</td><td>Duration</td><td>Lodging</td><td>Grade</td></tr>";
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[6], $myrow[7], $myrow[8], $myrow[9]);
echo "</table>\n";
}
while ($myrow = mysql_fetch_row($result3);
?>
</body>
Can anyone help?