943,678 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 14805
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jan 9th, 2009
0

Re: php code to search and show results on same page

more than you can ever read, compiled so you can find the part you need to read
http://www.php.net/docs.php
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jan 10th, 2009
0

Re: php code to search and show results on same page

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phpNewbie is offline Offline
13 posts
since Jan 2009
Feb 5th, 2009
0

Re: php code to search and show results on same page

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.

<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>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
phpNewbie is offline Offline
13 posts
since Jan 2009
Jan 4th, 2011
0
Re: php code to search and show results on same page
hi i am working in search module i never worked before in search module,Please do some Help in search Module for better understanding "php code to search and show results on same page"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wacmo is offline Offline
2 posts
since Oct 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: mysql to pdf convert
Next Thread in PHP Forum Timeline: about web hosting





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC