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 search issue

Thread began 5/06/2017 8:44 pm by EmmaMorris | Last modified 9/01/2017 3:45 pm by EmmaMorris | 1848 views | 7 replies

EmmaMorris

MySqli search issue

Ok..I have to ask for some input.. been working on this most of the day and although I am getting closer I am now at a loss.
On my main admin page, I want to include a search area so the admin can search for several fields.

Here is the code. I actually got most of it from a post here and modified it for my needs. I am not getting any errors that I can tell. Just no results.
Here is the form code and the table to display the results.. What am I missing?

<form name="admsrch" method="get" action="">
Enter Record #, Last Name or License Number to search.
<br>

<table width="400" border="0">
<tr>
<td width="195" align="right">Record #</td>
<td width="195"><label for="mainID"></label>
<input name="mainID" type="text" id="mainID" size="30"></td>
</tr>
<tr>
<td align="right">Last Name</td>
<td><label for="lastName"></label>
<input name="lastName" type="text" id="lastName" size="30"></td>
</tr>
<tr>
<td align="right">License Number</td>
<td><label for="licenseNumber"></label>
<input name="licenseNumber" type="text" id="licenseNumber" size="30"></td>
</tr>
</table>
<br>
<input type="submit" name="submit" id="submit" value="Submit">
</form>

<table width="500" border="0">
<tr>
<td>Record Number</td>
<td>Last Name</td>
<td>License Number</td>
</tr>
<?php
while(!$rsResults->atEnd()) {
?>
<tr>
<td>
<?php echo($rsResults->getColumnVal("mainID")); ?></td>
<td><?php echo($rsResults->getColumnVal("lastName")); ?></td>
<td><?php echo($rsResults->getColumnVal("licenseNumber")); ?></td>
</tr> <?php
$rsResults->moveNext();
}
$rsResults->moveFirst(); //return RS to first record
?>
</table>

and here is the php I have.

<?php
$rsResults = new WA_MySQLi_RS("rsResults",$conn_mdb1,0);
$rsResults->setQuery("SELECT * FROM maintbl WHERE mainID LIKE ? OR lastName LIKE ? AND licenseNumber LIKE ? ORDER BY mainID ASC");
$rsResults->bindParam("i", "".(isset($_GET['mainID'])?$_GET['mainID']:"") ."", "-1"); //colname
$rsResults->bindParam("s", "".(isset($_GET['firstName'])?$_GET['firstName']:"") ."", "-1"); //paramNam
$rsResults->bindParam("s", "".(isset($_GET['licenseNumber'])?$_GET['licenseNumber']:"") ."", "-1"); //paramLic
$rsResults->execute();
?>
Thanks ahead of time.

New Update.. Fixed a couple of misspels firstName should be lastName and one other. I got it to search by all 3 fields by changing the ANDs to ORs. Is that correct?

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

Content

rating

Layout

rating

Ease of use

rating

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