| | |
php code to search and show results on same page
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved
![]() |
more than you can ever read, compiled so you can find the part you need to read
http://www.php.net/docs.php
http://www.php.net/docs.php
Failure is not an option It's included free
If at first you dont succeed, join the club
Please mark solved problems, solved
If at first you dont succeed, join the club
Please mark solved problems, solved
•
•
Join Date: Jan 2009
Posts: 13
Reputation:
Solved Threads: 0
enim213 - thank you very much for the links you supplied - i really do appreciate your time to give them and will definitely make an effort to get the understanding - be afraid lol - if i come up with anything i'll be right back here for you to debug
(or get your pasted code - kidding - or not lol)
thank you almostbob for your link and code too
at least today i got my basic html page made and my database loaded so that's a start
(or get your pasted code - kidding - or not lol)thank you almostbob for your link and code too
at least today i got my basic html page made and my database loaded so that's a start
•
•
Join Date: Jan 2009
Posts: 13
Reputation:
Solved Threads: 0
Hi... i'm baaack
Ok.. i made some effort (got myself more confused in the process - seem to be so many ways to do the same thing??)
Anyway.. this is what i have now: Please help to add or change code to get this working. my sql statement works in phpmyadmin bringing back required results from the database but how do i get that happening on my webpage with the php and html.
Apologies for my messy code but like i explained before, i'm absolutely new to php and finding it very difficult to get my 'blonde' head around it.
Thanks again in advance for any help.
Ok.. i made some effort (got myself more confused in the process - seem to be so many ways to do the same thing??)
Anyway.. this is what i have now: Please help to add or change code to get this working. my sql statement works in phpmyadmin bringing back required results from the database but how do i get that happening on my webpage with the php and html.
Apologies for my messy code but like i explained before, i'm absolutely new to php and finding it very difficult to get my 'blonde' head around it.
Thanks again in advance for any help.
<html> <head> <title>Baby Names Database</title> </head> <body> <h1>Baby Names</h1> <h3>Please fill in the blanks below, and We'll return baby names for you to browse.</h3> <form method = "post" action = "practiceBaby5.php"> <table border = "1"> <tr> <th align = "left">Gender:</th> <th> <input type = "radio" name = "male" value = "yes">Boys Names<br /> <input type = "radio" name = "female" value = "yes">Girls Names<br /> </th> <tr> <th align = "left">Meaning:</th> <th> <input type = "text" name = "meaning" value = ""> </th> </tr> <tr> <th align = "left">Name Begins With:</th> <th> <input type = "text" name = "name" value = ""> </th> </tr> <tr> <th align = "left">Origin</th> <th> <select name = "origin"> <option value = "Muslim">Muslim</option> <option value = "anglo">Anglo</option> <option value = "african">African</option> <option value = "celtic">Celtic</option> </select> </th> </tr> <tr> <td colspan = 2> <br /> <center> <input type = "submit" value = "Show me Names"> </center> </td> </tr> </table> </form> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<?
// MySQL Connection Information
$server = "localhost";
$username = "sharlene";
$password = "";
$dbname = "baby_names";
// MySQL Connect String
$connection = mysql_connect($server,$username,$password);
// Select the database
mysql_select_db($dbname);
$gender = $_POST['gender'];
$meaning = $_POST['meaning'];
$name = $_POST['name'];
$origin = $_POST['origin'];
$gender = mysql_real_escape_string($gender);
$meaning = mysql_real_escape_string($meaning);
$name = mysql_real_escape_string($name);
$origin = mysql_real_escape_string($origin);
$sql = "SELECT * FROM names WHERE gender = '" . $gender . "' and name LIKE '" . $name . "%' and
meaning LIKE '%" . $meaning . "%' and origin = '" . $origin . "'";
//print($sql);
//execute SQL query and get result
$sql_result = mysql_query($sql, $connection)
or die(mysql_error());
//print("after sql");
// Loop through the data set and extract each row into it's own variable set
while ($row = mysql_fetch_array($sql_result)) {
extract($row);
}
// Loop through the data set and extract each row into it's own variable set
//while ($row = mysql_fetch_array($sql_result)) {
// echo $row['gender']." ".$row['meaning']." ".$row['name']." ".$row['origin']."<br>";
?>
</BODY>
</HTML>![]() |
Similar Threads
- How to limit page numbers for search results for database website (PHP)
- PLS I NEED YOUR HELP! Help on Reading and Editing of already Written CODE on php! (PHP)
- Using PHP/HTML to update informationin MySQL (PHP)
- delete and refresh search results (JavaScript / DHTML / AJAX)
- Problem with page navigation (PHP)
- Problem with PHP Search Code.... (PHP)
- multiple search terms+fulltext search (MySQL)
- php results from form - stuck (PHP)
- search and results question. (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP Friends request system!
- Next Thread: Validation of form
| Thread Tools | Search this Thread |
apache api array basic beginner broken cache cakephp class cms code computing confirm countingeverycharactersfromastring cron curl customizableitems database date delete dynamic echo email error fcc file filter folder form forms forum freelancing function functions gc_maxlifetime google header headmethod howtowriteathesis href htaccess html iframe image include incode ip javascript joomla limit link login malfunction match memmory memory menu method mod_rewrite multiple mysql navigation neutrality oop pagerank parsing paypal pdf php phpmysql query question random recursiveloop root script search select server sessions sms snippet soap source space sql support! system table template thesishelp trouble tutorial upload url variable video web window.onbeforeunload=closeme; youtube






