Search result hyperlink not working
Moderator: General Moderators
Re: Search result hyperlink not working
FYI, this is the error I keep getting:
Warning: Cannot modify header information - headers already sent by (output started at C:\Documents and Settings\Desktop\Project\searchprocess.php:7) in C:\Documents and Settings\Desktop\Project\searchprocess.php on line 33
Warning: Cannot modify header information - headers already sent by (output started at C:\Documents and Settings\Desktop\Project\searchprocess.php:7) in C:\Documents and Settings\Desktop\Project\searchprocess.php on line 33
Re: Search result hyperlink not working
Ok...one other thing with regards to the search function...I want to search for all types of properties within a certain area of London in my search function, but unfortunately, it doesn't seem to work. It keeps coming up with "There are no records returned for your search query.", which is an indication of the failure of the function.
Here is the code for that query:
Here is the code for that query:
Code: Select all
<?
//select the table
if($_POST['propertyType']=="No Preference" && $_POST['postcode']){
$result = mysql_query("SELECT * FROM property WHERE propertyArea = '$_POST[postcode]' ORDER BY `propertyID` ASC");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
?>
<tr>
<td>
<font face="Arial" color="#0B3A62">
<?
// Echo them out
echo "<a href=\"searchprocess.php?id=$row[propertyID]\">$row[propertyType]". ", £". $row[propertyPrice];
}
}
?>
Re: Search result hyperlink not working
The header warning is you cannot use start_session() or setcookie() once you have sent something to the screen (anything in HTML, an echo or a print in php).
The other part:
not sure how PHP reacts to backticks, use single quotes instead.
im not sure if you have to, but use quotes inside the $row[ ], I don't think it matters which quote but I use the above method usually
The other part:
Code: Select all
....`propertyID` ASC"
Code: Select all
echo '<a href="searchprocess.php?id='.$row["propertyID"].'">'.$row["propertyType"].', £'.$row["propertyPrice"];
Re: Search result hyperlink not working
Changing the backticks to single quotes didn't work for some reason...
It's really weird...I know this query is supposed to work...but it isn't...
It's really weird...I know this query is supposed to work...but it isn't...
Re: Search result hyperlink not working
You must use the link shown two posts above to concatenate in the variables in the URL.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Re: Search result hyperlink not working
The URL isn't the problem...
The problem lies in the SQL query in the code four posts up...
Thanks in advance, Scottayy...
Btw, thank you so much to kryles for being a MAJOR help over these past coupla days! This is actually my final-year dissertation...and if I get a good mark in this, part of the credit will be given to you for helping me
The problem lies in the SQL query in the code four posts up...
Thanks in advance, Scottayy...
Btw, thank you so much to kryles for being a MAJOR help over these past coupla days! This is actually my final-year dissertation...and if I get a good mark in this, part of the credit will be given to you for helping me
Re: Search result hyperlink not working(SOLVED)
I solved the search query!!
Code: Select all
<?
//select the table
if(!$_POST['propertyType']=="House" && !$_POST['propertyType']=="Flat" && !$_POST['propertyType']=="Bungalow" && $_POST['postcode']){
$result = mysql_query("SELECT * FROM property WHERE propertyArea = '$_POST[postcode]' ORDER BY 'propertyID' ASC");
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
?>
<tr>
<td>
<font face="Arial" color="#0B3A62">
<?
// Echo them out
echo "<a href=\"searchprocess.php?id=$row[propertyID]\">$row[propertyType]". ", £". $row[propertyPrice];
}
}
?>
Re: Search result hyperlink not working
was I right with the backticks instead of the single quote?
Re: Search result hyperlink not working
Erm...unfortunately not...sorry kryles!
It was just something to do with if statement conditions...but it works...yay!
Ok...some more problems...
...they keep on coming!
This is a different kinda search...advanced search...need to search for properties within a specific search criteria specified by price as well as property type:
Now...I think it might be a problem with the HTML form...OR a problem with the query...but I'm not quite sure. I'm gonna keep checking. In the meantime, if anyone can see where I've gone wrong, then please do not hesitate to let me know on this thread! 
It was just something to do with if statement conditions...but it works...yay!
Ok...some more problems...
This is a different kinda search...advanced search...need to search for properties within a specific search criteria specified by price as well as property type:
Code: Select all
<?
//select the table
if(!$_POST['propertyType']=="House" && !$_POST['propertyType']=="Flat" && !$_POST['propertyType']=="Bungalow" && !$_POST['postcode'] && $_POST['propertyPriceMin'] && $_POST['propertyPriceMax']){
$result = mysql_query("SELECT * FROM property WHERE propertyPrice BETWEEN '$_POST[propertyPriceMin]' AND '$_POST[propertyPriceMax]' ORDER BY 'propertyID' ASC");
Re: Search result hyperlink not working
echo out the $_POST[ ] variables to see if you are getting what you expect from the form
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Search result hyperlink not working
simpler than echo'ing arrays, use var_dump(), or print_r()
Code: Select all
echo '<pre>'. print_r($_POST, true) .'</pre>';