Drink with All Things Cheesy


"; function build_form($origin,$target) { $form_top="
"; $form_submit="

"; $form_end="

"; $query="SELECT DISTINCT $origin FROM lisaraps.cheesedrinktable ORDER BY '$origin'"; $result=mysql_query($query); print "
Search for $target suggestions by $origin:
"; print $form_top; print "

$form_submit

"; } function process_form($origin,$target) { $type=$_GET['type']; $query="SELECT * FROM lisaraps.cheesedrinktable WHERE $target='$type'"; $result=mysql_query($query); $error=mysql_error(); if($error) { print "mySQL query:$query
"; print "mySQL error:$error
"; } print "

Here you go!

"; // for results $columns=mysql_fetch_array($result); $drink = $columns['drink']; $cheese = $columns['cheese']; if($target=='cheese'){ $display_block .= "

$cheese is tasty with $drink ,"; } if($target=='drink'){ $display_block .= "

$drink flatters $cheese ,"; } while($columns=mysql_fetch_array($result)) { $id = $columns['id']; $drink = $columns['drink']; $cheese = $columns['cheese']; if($target=='cheese') { $display_block .= " $drink "; } if($target=='drink') { $display_block .= " $cheese "; } } print " $display_block .

"; } if ($_GET['submitted'] == 'search cheese') { process_form('cheese','drink'); print "$search_again"; } else if ($_GET['submitted'] == 'search drink') { process_form('drink','cheese'); print "$search_again"; } else { build_form('cheese','drink'); build_form('drink','cheese'); } print "

"; print "
"; ?>
View all drink and cheese suggestions.

"For every wound, a balm. For every storm, a beer."

Valid XHTML 1.0!