Jump to content

Recommended Posts

Hello, I'm currently building a database of local businesses, I'm quite new to using php and mysql. While I'm mostly managing to stumble my through it, a couple of things are confusing me. This is one of the things. If anyone can help, that would be really great.

 

Ok, so I've build a search page, and a results page and it works great but there is one problem. Currently it will only search through the 'name' column, but I'd also like it to search through the 'type' column at the same time.

 

This is the code I'm using to fetch the results

$colname_Businesses = "-1";
if (isset($_POST['search_par'])) {
  $colname_Businesses = $_POST['search_par'];
}
mysql_select_db($database_HBBA_DATABASE, $HBBA_DATABASE);
$query_Businesses = sprintf("SELECT * FROM Businesses WHERE name LIKE %s", GetSQLValueString("%" . $colname_Businesses . "%", "text"));
$query_limit_Businesses = sprintf("%s LIMIT %d, %d", $query_Businesses, $startRow_Businesses, $maxRows_Businesses);
$Businesses = mysql_query($query_limit_Businesses, $HBBA_DATABASE) or die(mysql_error());
$row_Businesses = mysql_fetch_assoc($Businesses);

 

I'm not sure what to add in to make it also search through the 'type' column or where to put that. Can anyone point me in the right direction? Any help would be most appreciated.

 

Cheers

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/63902-solved-searching-multiple-mysql-columns/
Share on other sites

just 1 value to search for in both columns.

 

so, if i was searching for the word 'book' it would return any entries from names with the work book in (like 'the book case') and any entries form the type column with the work book in (like 'book restoration')

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.