close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

MySQLi Query Builder only returning one match when other matches are available + how to add an "any" option

Thread began 10/08/2015 6:28 am by Nathon Jones Web Design | Last modified 10/08/2015 7:07 pm by Nathon Jones Web Design | 729 views | 3 replies

Nathon Jones Web Design

MySQLi Query Builder only returning one match when other matches are available + how to add an "any" option

I have an events search facility with two search options - Type of Event and Keyword.

Type of Event is database driven and I'm checking for events that have a specific ID when searched. Keyword is obvious enough.

This is my search form:

<form class="form-horizontal" name="searcheventsFORM" id="searcheventsFORM" method="post" action="traditional-music-events-search.php">
<div class="form-group">
<label for="searchTYPE" class="col-sm-4 control-label">Type of Event:</label>
<div class="col-sm-8">
<select id="searchTYPE" name="searchTYPE" class="form-control" tabindex="1">
<option value="">Any</option>
while(!$rsEVENTTYPE->atEnd()) {
<option value="<?php echo($rsEVENTTYPE->getColumnVal("tmsaeventtypeID")); ?>"><?php echo($rsEVENTTYPE->getColumnVal("tmsaeventtype")); ?></option>
$rsEVENTTYPE->moveFirst(); //return RS to first record

<div class="form-group">
<label for="searchKEYWORD" class="col-sm-4 control-label">Search:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="searchKEYWORD" name="searchKEYWORD" placeholder="Keyword/s, town/city, region..." maxlength="100" tabindex="2">

<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<button type="submit" class="btn btn-default" name="searcheventsBTN" tabindex="3"><span class="glyphicon glyphicon-search"></span> Search</button>
</div><!-- end form-group -->

This is my MySQLi Query Builder recordset:

$rsEVENTS = new WA_MySQLi_RS("rsEVENTS",$csdbmysqli,0);
$rsEVENTS->setQuery("SELECT TMSAevent.tmsaeventID, TMSAevent.tmsaeventtypeID, TMSAevent.tmsaevent, TMSAevent.tmsastartdate, TMSAevent.tmsaenddate, TMSAevent.tmsavenueID, TMSAevent.tmsaeventsummary, TMSAevent.tmsaeventdesc, TMSAevent.tmsaeventDELETE, TMSAevent.tmsaeventPHONE, TMSAevent.tmsaeventEMAIL, TMSAevent.tmsaeventWEB, TMSAvenues.tmsavenuename, TMSAvenues.tmsaorgname, TMSAvenues.tmsavenuecontactname, TMSAvenues.tmsavenueaddress, TMSAvenues.tmsavenuetown, TMSAvenues.tmsavenuepostcode, TMSAcountry.tmsacountry, TMSAregions.tmsaregion FROM TMSAevent INNER JOIN TMSAvenues ON TMSAevent.tmsavenueID = TMSAvenues.tmsavenueID INNER JOIN TMSAcountry ON TMSAvenues.tmsacountryID = TMSAcountry.tmsacountryID INNER JOIN TMSAregions ON TMSAvenues.tmsaregionID = TMSAregions.tmsaregionID WHERE TMSAevent.tmsaeventtypeID = ? AND TMSAevent.tmsastartdate >= ? AND (TMSAevent.tmsaevent LIKE ? OR TMSAevent.tmsaeventsummary LIKE ? OR TMSAevent.tmsaeventdesc LIKE ? OR TMSAvenues.tmsavenuename LIKE ? OR TMSAvenues.tmsaorgname LIKE ? OR TMSAvenues.tmsavenuecontactname LIKE ? OR TMSAvenues.tmsavenueaddress LIKE ? OR TMSAvenues.tmsavenuetown LIKE ? OR TMSAregions.tmsaregion LIKE ? OR TMSAcountry.tmsacountry LIKE ?)");
$rsEVENTS->bindParam("i", "".(isset($_POST['searchTYPE'])?$_POST['searchTYPE']:"") ."", "-1"); //WAQB_Param1
$rsEVENTS->bindParam("t", "".(isset($_SESSION['todaySESH'])?$_SESSION['todaySESH']:"") ."", "-1"); //WAQB_Param2
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param3
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param4
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param5
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param6
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param7
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param8
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param9
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param10
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param11
$rsEVENTS->bindParam("c", "".(isset($_POST['searchKEYWORD'])?$_POST['searchKEYWORD']:"") ."", "-1"); //WAQB_Param12

You can try this out here...

Here are the problems with it...

1. When I select "Any" as the Type of Event, and leave the Keyword field blank no results are returned. This should return all of the events.

2. When I select a Type of Event, for example "Festival", and leave the keyword field blank only one result is returned yet there is more than one Festival event in the database.

3. If I select "Festival" as the Type of Event and type the Keyword "Newton" I am shown a festival event that doesn't appear in the search in step 2 above?

Something is clearly wrong with the MySQLi Query Builder or, more likely, my understanding of how this should work. Either way I'd appreciate some help resolving it as it's pretty useless in its current format.

Appreciate it. Thank you.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...