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>