From: "phplist" <[EMAIL PROTECTED]>
> I've tried further, and still came up short. This time, if I use the % -
> it returns nothing.
Here's another way to do it, using PHP:
<?php
if (!subject) {
header("Location: nowhere.html");
exit;
}
// Connects to database
include("cnx_db.inc");
// First addslashes to text:
$formatted_subject = addslashes($subject);
// Formats Query
// New way to format $sql below:
$sql = "SELECT * FROM links WHERE (SUBJECT1='$formatted_subject' OR
SUBJECT2='$formatted_subject') ";
// check to see if $geographic has been selected. the value for the
// default option should be empty in the originating HTML form
if ($geographic) $sql .= "AND GEOGRAPHIC='$geographic' ";
$sql .= "ORDER BY ORGANIZATION ASC";
// End new $sql formatting
print($sql);
$sql_result = mysql_query($sql);
if (!$sql_result) {
echo "Can't execute $sql " . mysql_error();
exit;
}
// organizes data in an orderly manner (ie bulleted area)
while ($row = mysql_fetch_array($sql_result)) {
$esc_organization = $row["ORGANIZATION"];
$esc_desc = $row["DESCRIPTION"];
$esc_url = $row["URL"];
$esc_subject1 = $row["SUBJECT1"];
$esc_subject2 = $row["SUBJECT2"];
$esc_geographic = $row["GEOGRAPHIC"];
$organization = stripslashes($esc_organization);
$description = stripslashes($esc_desc);
$url = stripslashes($esc_url);
$subject1 = stripslashes($esc_subject1);
$subject2 = stripslashes($esc_subject2);
$geographic = stripslashes($esc_geographic);
$option_block .= "<li><b>Organization:</b> <a
href=\"http://$url\">$organization</a><br><b>Geographic Region:</b>
$geographic<br><b>Description:</b> $description<br><b>URL:</b> <a
href=\"http://$url\">$url</a></li><br><b>Subject1:</b>
$subject1<br><b>Subject2:</b> $subject2\n"; } include("byebye.inc");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test Result</title>
</head>
<body>
<h1><?php echo $subject; ?></h1>
You have chosen <?php echo $subject; ?>. Here are the results: <Ul>
<?php echo $option_block; ?> </UL>
</body>
</html>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php