mrtom100
02-22-2007, 01:16 PM
I need help trying to get a advance search to work on a site i am building can some one give me some advise on my code please as the solution is beyond me.
<?php
include('menu.php');
// keyword put into the search text box is assigned to $new
$new = $_POST['artist'];
$new1 = $_POST['title'];
$new2 = $_POST['author'];
$new3= $_POST['pyear'];
?>
<!--Center colum of the webpage-->
<?
// selects the fields to display and the table to which the search will look in and which field the search will look up the keyword in.
$sql =("SELECT title, author, artist, yearpublished, publisher FROM comics WHERE title LIKE \"%$tnew%"" AND WHERE author Like \"%$tnew1%"" AND WHERE publishedyear Like \"%$tnew2%"" AND WHERE artist LIKE \"%$tnew3% \"");
// gives the result a varible name $queryResult
$queryResult = mysql_query($sql);
if (mysql_error())
{
echo "Problem with Query<BR>";
echo "The following error message was returned from MySQL:<BR>";
echo mysql_error();
exit;
}
// if there are no results print the message
if (mysql_num_rows($queryResult)==0)
{
echo "No records exist containing the word $new, $new1, $new2, $new3";
}
//if there are more than 0 results print message and list results
if (mysql_num_rows($queryResult)>0){
print "We have found ".mysql_num_rows($queryResult)." results with ".$new.$new1.$new2.$new3." in the title.<BR><BR>";
}
// for each record displayed show title, artist, yearpublished, publisher
while ($dbRecord=mysql_fetch_array($queryResult))
{
echo $dbRecord["title"].", ".$dbRecord["artist"].", ".$dbRecord["yearpublished"].", ".$dbRecord["publisher"]."<hr><BR>";
}
?>
can any one help ..? i havent included the connection part as i know that works fine
<?php
include('menu.php');
// keyword put into the search text box is assigned to $new
$new = $_POST['artist'];
$new1 = $_POST['title'];
$new2 = $_POST['author'];
$new3= $_POST['pyear'];
?>
<!--Center colum of the webpage-->
<?
// selects the fields to display and the table to which the search will look in and which field the search will look up the keyword in.
$sql =("SELECT title, author, artist, yearpublished, publisher FROM comics WHERE title LIKE \"%$tnew%"" AND WHERE author Like \"%$tnew1%"" AND WHERE publishedyear Like \"%$tnew2%"" AND WHERE artist LIKE \"%$tnew3% \"");
// gives the result a varible name $queryResult
$queryResult = mysql_query($sql);
if (mysql_error())
{
echo "Problem with Query<BR>";
echo "The following error message was returned from MySQL:<BR>";
echo mysql_error();
exit;
}
// if there are no results print the message
if (mysql_num_rows($queryResult)==0)
{
echo "No records exist containing the word $new, $new1, $new2, $new3";
}
//if there are more than 0 results print message and list results
if (mysql_num_rows($queryResult)>0){
print "We have found ".mysql_num_rows($queryResult)." results with ".$new.$new1.$new2.$new3." in the title.<BR><BR>";
}
// for each record displayed show title, artist, yearpublished, publisher
while ($dbRecord=mysql_fetch_array($queryResult))
{
echo $dbRecord["title"].", ".$dbRecord["artist"].", ".$dbRecord["yearpublished"].", ".$dbRecord["publisher"]."<hr><BR>";
}
?>
can any one help ..? i havent included the connection part as i know that works fine