| | |
search from database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2008
Posts: 141
Reputation:
Solved Threads: 6
hi frnds,
i am doing a project related to food items..
here i took different categories like restaurants,pubs,foodfestivals,hangouts...
and also i took diffrent tables for each category in database..
each table having area,rname...now i need to search what ever user typed in textbox(area,rname) from database.
plz give any suggestions asap..
i am doing a project related to food items..
here i took different categories like restaurants,pubs,foodfestivals,hangouts...
and also i took diffrent tables for each category in database..
each table having area,rname...now i need to search what ever user typed in textbox(area,rname) from database.
plz give any suggestions asap..
My best wishes ... from my soul ... for everyone!
Keep Smiling....Never Depress
Keep Smiling....Never Depress
This is only from the top of my head but if what you place in those 2 fields (area, rname) need to match percisely what are in those 2 columns within the mysql database then you could use something along the following:
php Syntax (Toggle Plain Text)
<? //mysql connections if (isset($_POST['area']) && isset($_POST['rname'])) { $result=mysql_query("SELECT * FROM `table` WHERE `area`='".$_POST['area']."' AND `rname`='".$_POST['rname']."'"); echo "<table border=1 cellpadding=4 cellspacing=0><tr><td>area</td><td>rname</td><td>column3</td></tr>"; while ($rowid=mysql_fetch_array($result)) { //perform actions for earch row found echo "<tr><td>".$rowid['area']."</td>"; echo "<td>".$rowid['rname']."</td>"; echo "<td>".$rowid['column3']."</td></tr>"; } echo "</table>"; } ?> <form method='post'> area=<input type='text' name='area'><br> rname=<input type='text' name='rname'><br> <input type='submit' value='submit'> </form>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Hi...
What i suggest you is to create a category select box and its value should be the same as of your tablename.... (this is what you have done.. table for every category)
I hope too many php tags doesn't confuses you... Its just to display result in a better way...
What i suggest you is to create a category select box and its value should be the same as of your tablename.... (this is what you have done.. table for every category)
I hope too many php tags doesn't confuses you... Its just to display result in a better way...
php Syntax (Toggle Plain Text)
<?php if(isset($_POST['submit'])) { $sql="Select * from ".$_POST['category']." where area like '%".$_POST['area']."%' and rname like '%".$_POST['rname']."%' order by area asc"; $result = mysql_query($sql); ?> <table border="1"> <tr> <td colspan="2"> Search in table >> <?php echo $_POST['category']; ?></td> </tr> <?php if(mysql_num_rows($query) > 0) { while($row = mysql_fetch_array($result)) { ?> <tr> <td>$row['area'];</td> <td>$row['rname'];</td> </tr> <?php } } else { ?> <tr> <td colspan="2">No entry found</td> </tr> <?php } ?> </table> <?php } ?> <form name="form_search" method="post" action=""> Select Category <select name="category"> <option value="restaurants">Restaurants</option> <option value="restaurants">Restaurants</option> <option value="restaurants">Restaurants</option> <option value="restaurants">Restaurants</option> </select> <br/> Area <input type="text" name="area" id="area" /> <br /> Rname <input type="text" name="rname" id-"rname" /> <br /> <input type="submit" value="search" name="submit"> </form>
![]() |
Similar Threads
- VB6 Database Program (Visual Basic 4 / 5 / 6)
- search database using php (PHP)
- ASP Search Database (ASP)
- need help, to Search from database (ASP)
- Tutorial: Search a Database (ASP)
- mySQL database searching for registration (MySQL)
- force Search Page to return no records on open (ASP)
- able to search? (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: Passing form data to default file of a directory
- Next Thread: Category hierarchy problem............
| Thread Tools | Search this Thread |
# 5.2.10 access action address alexa apache api array auto autoincrement broken cakephp checkbox class classes clean clients cms code cron curl database date dehasher destroy directory dissertation domain dynamic echo$_get[x]changingitintovariable... email encode error errorlog fairness fatalerror file folder form function functions google href htaccess html image include indentedsubcategory ip javascript joomla legislation limit link load local login masterthesis memberships menu multiple multipletables mysql mysqlquery newsletters oop open passwords paypal pdf persist php popup provider query radio random script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube






