Jump to content

Search MYSQL Database using PHP Page then Use results.......


Recommended Posts

Hi All

 

Thanks in advance for this, I'm a newb so be gentle. I have searched the net for days trying to figure out how to essentially search a databsae from a php page (which I found references to do) but then couldnt work out how to then use the results rather than just return them on a page.

 

So I have a text box and submit button on one page, which I want to use to search particular fields in my database - I have the SQL for this but need to amend it to get the search string from my text box.

 

The results returned need to have a radio box or check box on each result which when select pulls out one specific field from the record and the variable passed on to an other page.

 

Hope all this makes sense, hope some one can help!  :D

Ok, very simple code for form with text box and submit button.

<form name="form">

  <input type="text" name="search" />

  <input type="submit" name="Submit" value="Search" />

</form>

 

SQL which needs amending to use the "search" text box.

Select Location_id, Postcode, Town from Locations where Location_id like '%B49%' or

Postcode like '%B49%' or Town like '%B49%'

 

There would be more fields but this isnt the issue, its replacing my criteria above '%B49' to refer to the content of the search box above.

 

Some code I found to do a search (but it has things in it that I dont need - e.g. connection details as these are called from an other PHP file).

 

http://www.homeandlearn.co.uk/php/php13p2.html

 

Would then need amending to have check boxes in order to select a particular field from a return record (would only every be one needed).

 

Hope this makes sense - helps.

 

 

 

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.