Search Problems with MySQL Database
Posted: Sun Dec 29, 2002 5:35 pm
Hi All,
I will try to be as clear as possible and hopefully ya'll can assist!!!
I have a MySQL with a table called audio, this database contains files that I have uploaded to my server so I can catalog them for future use.
The Problem!!!!!
I want to search by keywords I assigned to the file, as well as individually search by filename and other parameters. I can get the individual searches to work just fine but not my keyword search. I have 4 keywords fields in my table keywords1, keywords2, keywords3, keywords4. The below select statement is what I am using:
$keywords is my search box name: <input type "text" name="keywords">
$results12=mysql_query("select * from audio where keywords1='$keywords'");
if (mysql_num_rows ($results12)<1)
{
?>
error if nothing found
<?
}
This will return only keywords1 result but not search keywords2,3,and 4
I almost need it written like this:
$results12=mysql_query("select * from audio where keywords1,keywords2,keywords3,keywords4='$keywords'");
if (mysql_num_rows ($results12)<1)
{
When a keyword is found I am doing this:
if (mysql_num_rows ($results12)>0)
{
$results12=mysql_query("select keywords1,keywords2,keywords3,keywords4,filename,format,date,rate,size,comments from audio where keywords1 || keywords2='$keywords'");
while (list($keywords1,$keywords2,$keywords3,$keywords4,$filename,$format,$date,$rate,$size,$comments)=mysql_fetch_row($results12))
{
This echo's to the screen all my data I have assigned to the file
}
Can anyone please help? I am ok with php so please be very precise and submit the code exactly the way it should. Much thanks in advance!!!!
Aelaron
I will try to be as clear as possible and hopefully ya'll can assist!!!
I have a MySQL with a table called audio, this database contains files that I have uploaded to my server so I can catalog them for future use.
The Problem!!!!!
I want to search by keywords I assigned to the file, as well as individually search by filename and other parameters. I can get the individual searches to work just fine but not my keyword search. I have 4 keywords fields in my table keywords1, keywords2, keywords3, keywords4. The below select statement is what I am using:
$keywords is my search box name: <input type "text" name="keywords">
$results12=mysql_query("select * from audio where keywords1='$keywords'");
if (mysql_num_rows ($results12)<1)
{
?>
error if nothing found
<?
}
This will return only keywords1 result but not search keywords2,3,and 4
I almost need it written like this:
$results12=mysql_query("select * from audio where keywords1,keywords2,keywords3,keywords4='$keywords'");
if (mysql_num_rows ($results12)<1)
{
When a keyword is found I am doing this:
if (mysql_num_rows ($results12)>0)
{
$results12=mysql_query("select keywords1,keywords2,keywords3,keywords4,filename,format,date,rate,size,comments from audio where keywords1 || keywords2='$keywords'");
while (list($keywords1,$keywords2,$keywords3,$keywords4,$filename,$format,$date,$rate,$size,$comments)=mysql_fetch_row($results12))
{
This echo's to the screen all my data I have assigned to the file
}
Can anyone please help? I am ok with php so please be very precise and submit the code exactly the way it should. Much thanks in advance!!!!
Aelaron