Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   php help please (http://www.go4expert.com/forums/php-help-please-t25525/)

elina 14Apr2011 21:06

php help please
im very new to php. can anyone please help. im trying to create a search feature for my application which im using php and mysql. can you please give me the code for a simple search feature.

thank you

ManzZup 15Apr2011 20:37

Re: php help please
can you descripbe the search features
if you clearly know the app, you can base your search on the DB itself, and dynamically generate the required links
ex: you search for "best article"
you have a page named best artcle in your DB
you make link with the article ID
hope you got it :D

transparent 5May2011 12:56

Re: php help please
You need first to create a HTML form for the search

HTML Code:

<form action="search.php">
  <input type="text" name="s" />
  <input type="submit" value="Search" />

Now inside your search.php:
PHP Code:

// connect to the database
$con mysql_connect('localhost','username','password');

//create a search query
$find $_REQUEST['s'];
$q "SELECT * FROM `table_to_do_search` WHERE `field1` LIKE '%$find%' or `field2` LIKE '%$find%'";

$result mysql_query($q);

mysql_num_rows($result) > 0)
$row mysql_fetch_assoc($result))

'No results found';


This is just a concept on how it should work.

All times are GMT +5.5. The time now is 23:58.