Jump to content

Search drop down menu to choose mysql table


ljaii

Recommended Posts

Hey,

 

I have currently made a simple PHP search script which, when data is entered in a text box and it's submitted, it queries a table in a MYSQL database and returns information. This works. However, I want to have a combo box beside the text box with options to query different tables depending on which item in the combo is selected.

 

At the moment it searches a news articles table by content and title. But I want to adapt the script so that it searches another table which holds information on people for example.

 

It currently gets the item from the text box with the code:

 

$v = @$_GET['entered'] ;
  $entereddata = trim($v); 

 

Then queries the database with:

 

$query = "select * from news where content like \"%$entereddata%\" or title like \"%$entereddata%\"  
  order by date";

 

Is this possible to return results from different tables depending on the selection made in a combo box?

 

Thanks,

LJ

 

I'm pretty sure its possible I just don't know how to do it.  ???

 

UPDATED: on second thoughts this might work.

 

<form>
<input type="radio" name="table" value="<?=$table1?>"> Table 1
<br>
<input type="radio" name="table" value="<?=$table2?>"> Table 2
</form>

 

Regards ACE

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.