Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search page for a DB, then displaying results..

Status
Not open for further replies.

pjwraith

Technical User
May 17, 2002
12
GB
I am a newcomer to MYSQL, I have installed and designed/populated a simple online database and now need to design two simple webpages.

All i want to do is have a choice of searching on matches in 2 fields, the results being displayed in a further page.

i am not asking for someone to do this for me ;-) , but was hoping for somewhere I could go to for sample page designs or similar so i can understand how this is best achieved.

In essence,

1. I am assuming PHP code is the easiest way of achieving this?

2. Are there any recommended sites I could go to for sample pages/source code that would help me with this?

Many thanks for your help in advance.
 
Alot of MySQL users are PHP, but I guess im one to go the other direction, guess its cause I never picked up C... but I use asp.

But this question is more about your SQL statement then anything...

Ofcourse this for ASP...but it shouldnt be hard to understand..

<%

'// your form field name
frmSearch1 = Request.Form(&quot;frmSearch1&quot;)

'// your second form field
frmSearch2 = Request.Form(&quot;frmSearch2&quot;)

'// Databse Stuff...

sqlstatement = &quot;SELECT column1,column2 WHERE column1 LIKE ('%&quot; & frmSearch1& &quot;%') AND column2 LIKE ('%&quot; & frmSearch2 & &quot;%')&quot;&quot;

'// Execute database stuff...

'// loop through rows in db for search results...

If rs.eof then
'// records not found, display a message
Response.Write &quot;Records Not found!&quot;
else
Do while not rs.eof

Response.Write(&quot;<br>&quot; & rs(&quot;column1&quot;) & &quot; &quot; & rs(&quot;column2&quot;))

rs.movenext
loop


hope that helps
- Jason





%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top