can anyone help me with my php code. there is a problem between the receiving of the search function and displaying the result from the database.
this is the code that receives the two queries:
if ($postcode != ""){
$result=mysql_query("SELECT * FROM biz_details WHERE postcode = $postcode");
} else if ($postcode = ""){
$result=mysql_query("SELECT * FROM biz_details WHERE job_type = $category");
}
i can not tell what the problem is with it and need a second pair of eyes to find out my error.
this is the search page:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="details.php" method="post">
Postcode:
<br></br>
<input class="inputbox" type="text" name="postcode"
value=""
onBlur="if(this.value=='') this.value='';"
onFocus="if(this.value=='<?php echo _SEARCH_BOX; ?>') this.value='';" />
<input type="hidden" name="option" value="search" />
<input type="submit" name="lero" value="Go" class="button">
</form>
<form action="details.php" method="post">
<br></br>
Business Types:
<br></br>
<select name="category">
<option value="Air Conditioning & Heating Installation
">Air Conditioning & Heating Installation
</option>
<option value="Audiovisual Equipment Installation
">Audiovisual Equipment Installation
</option>
<option value="Bathroom Renovation
">Bathroom Renovation
</option>
<option value="Bricklaying">Bricklaying</option>
<option value="Building Construction">Building Construction
</option>
<option value="Building Supplies">Building Supplies</option>
<option value="Carpenter">Carpenter</option>
<option value="Plasterer">plasterer</option>
<option value="Cleaning">Cleaning</option>
<option value="Gardner">Gardner</option>
<option value="Landscaper">Landscaper</option>
<option value="Car Mechanic">Car Mechanic</option>
<option value="Glass man">Glass man</option>
<option value="Construction">Construction</option>
</select>
<input type="submit" name="lero1" value="Go" class="button">
</form>
</body>
</html>
and this is the recieving page
<?php
$postcode = $_POST["postcode"];
$category = $_POST["category"];
//this code below is required anytime you want to connect to the database
mysql_connect("localhost","root","");
mysql_select_db("biz_details");
//the variable $result holds an array of data
//from the SQL query that you write
if ($postcode != ""){
$result=mysql_query("SELECT * FROM biz_details WHERE postcode = $postcode");
} else if ($postcode = ""){
$result=mysql_query("SELECT * FROM biz_details WHERE job_type = $category");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>business Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
.style1 {
color: #FF9900;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><p class="style2">Â*</p>
<p class="style1">Search for magazines:</p>
<form action="ressearch.php" method="GET">
<table width="800" border="1" cellpadding="0" cellspacing="0">
<tr>
<td><strong>Business Name:</strong></td>
<td><strong>Job Type:</strong></td>
<td><strong>Phone Number:</strong></td>
<td><strong>fax:</strong></td>
</tr>
<tr>
</tr>
<?php
//loop: until you have gone through all the rows returned from the database,
// print a new table row, and display the data in this row
// if there is another row of data from the database, do it again.
while ($row=mysql_fetch_array($result))
{
print "
<tr>
<td>$row[job_title]</td>
<td>$row[job_type]</td>
<td>$row[phone_number]</td>
<td>$row[fax]</td>
<td><a href=\"ressearch.php?bizid=$row[biz_id]\">More Details...</a></
this is the code that receives the two queries:
if ($postcode != ""){
$result=mysql_query("SELECT * FROM biz_details WHERE postcode = $postcode");
} else if ($postcode = ""){
$result=mysql_query("SELECT * FROM biz_details WHERE job_type = $category");
}
i can not tell what the problem is with it and need a second pair of eyes to find out my error.
this is the search page:
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form action="details.php" method="post">
Postcode:
<br></br>
<input class="inputbox" type="text" name="postcode"
value=""
onBlur="if(this.value=='') this.value='';"
onFocus="if(this.value=='<?php echo _SEARCH_BOX; ?>') this.value='';" />
<input type="hidden" name="option" value="search" />
<input type="submit" name="lero" value="Go" class="button">
</form>
<form action="details.php" method="post">
<br></br>
Business Types:
<br></br>
<select name="category">
<option value="Air Conditioning & Heating Installation
">Air Conditioning & Heating Installation
</option>
<option value="Audiovisual Equipment Installation
">Audiovisual Equipment Installation
</option>
<option value="Bathroom Renovation
">Bathroom Renovation
</option>
<option value="Bricklaying">Bricklaying</option>
<option value="Building Construction">Building Construction
</option>
<option value="Building Supplies">Building Supplies</option>
<option value="Carpenter">Carpenter</option>
<option value="Plasterer">plasterer</option>
<option value="Cleaning">Cleaning</option>
<option value="Gardner">Gardner</option>
<option value="Landscaper">Landscaper</option>
<option value="Car Mechanic">Car Mechanic</option>
<option value="Glass man">Glass man</option>
<option value="Construction">Construction</option>
</select>
<input type="submit" name="lero1" value="Go" class="button">
</form>
</body>
</html>
and this is the recieving page
<?php
$postcode = $_POST["postcode"];
$category = $_POST["category"];
//this code below is required anytime you want to connect to the database
mysql_connect("localhost","root","");
mysql_select_db("biz_details");
//the variable $result holds an array of data
//from the SQL query that you write
if ($postcode != ""){
$result=mysql_query("SELECT * FROM biz_details WHERE postcode = $postcode");
} else if ($postcode = ""){
$result=mysql_query("SELECT * FROM biz_details WHERE job_type = $category");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>business Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
.style1 {
color: #FF9900;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
<body>
<table width="900" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><p class="style2">Â*</p>
<p class="style1">Search for magazines:</p>
<form action="ressearch.php" method="GET">
<table width="800" border="1" cellpadding="0" cellspacing="0">
<tr>
<td><strong>Business Name:</strong></td>
<td><strong>Job Type:</strong></td>
<td><strong>Phone Number:</strong></td>
<td><strong>fax:</strong></td>
</tr>
<tr>
</tr>
<?php
//loop: until you have gone through all the rows returned from the database,
// print a new table row, and display the data in this row
// if there is another row of data from the database, do it again.
while ($row=mysql_fetch_array($result))
{
print "
<tr>
<td>$row[job_title]</td>
<td>$row[job_type]</td>
<td>$row[phone_number]</td>
<td>$row[fax]</td>
<td><a href=\"ressearch.php?bizid=$row[biz_id]\">More Details...</a></