ianhaney Posted May 4, 2012 Share Posted May 4, 2012 Hi I have got results being displayed after clicking the search button in a form on my home page but it brings up all the results which is ok but how do I get onlt the results a user searches for for example a location or property type etc as its for a property website The coding is below for the results page Also sorry how do I add a background image to the php page, I tried using css but wouldn't work <style type="text/css"> body {background-image:url('images/greybgone.png');} </style> <?php mysql_connect ("2up2downhomes.com.mysql", "2up2downhomes_c","mD8GsJKQ") or die (mysql_error()); mysql_select_db ("2up2downhomes_c"); echo $_POST['term']; $sql = mysql_query("select * from properties where typeProperty like '%$term%' or location like '%$term%'"); while ($row = mysql_fetch_array($sql)){ echo 'Type of Property: '.$row['typeProperty']; echo '<br/> Number of Bedrooms: '.$row['bedrooms']; echo '<br/> Number of Bathrooms: '.$row['bathrooms']; echo '<br/> Garden: '.$row['garden']; echo '<br/> Description: '.$row['description']; echo '<br/> Price: '.$row['price']; echo '<br/> Location: '.$row['location']; echo '<br/> Image: '.$row['image']; echo '<br/><br/>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/ Share on other sites More sharing options...
litebearer Posted May 4, 2012 Share Posted May 4, 2012 follow this similar thread http://www.phpfreaks.com/forums/index.php?topic=358846.0 Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/#findComment-1342982 Share on other sites More sharing options...
kiqeri Posted May 8, 2012 Share Posted May 8, 2012 hello, maybe you should add $term=$_POST['term']; because when you hit 'search', the keyword you are searching is saved in $_POST['term'] so the $term in your sql instruction is equal to blank, which make it gives you all the result. Hope it helps : ) Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/#findComment-1343875 Share on other sites More sharing options...
ManiacDan Posted May 8, 2012 Share Posted May 8, 2012 Change your mysql password immediately, you've posted it on the internet. Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/#findComment-1343974 Share on other sites More sharing options...
downah Posted May 8, 2012 Share Posted May 8, 2012 your a moderator can't you edit the post to do the guy a favour? :'( Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/#findComment-1343977 Share on other sites More sharing options...
Jessica Posted May 8, 2012 Share Posted May 8, 2012 your a moderator can't you edit the post to do the guy a favour? :'( If they edit it, that won't change the fact that other people saw it first. He should still change it. Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/#findComment-1343988 Share on other sites More sharing options...
ManiacDan Posted May 8, 2012 Share Posted May 8, 2012 That password is now permanently compromised. If I changed it, he would be lazy and not change it himself. By leaving it here, he's forced to do the right thing. Quote Link to comment https://forums.phpfreaks.com/topic/262066-displaying-results-from-a-mysql-database/#findComment-1344017 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.