Jump to content

Please Help!!


lollabelt

Recommended Posts

I am trying to build a yellowpages site that searches the database, and comes up with only a few fields (like name, address, phone) but gives a link to a more complete page with all the database fields echoed on to the page...Here is the code I have so far...(Please Note I am a total beginner php)... Right now I am just doing the MYsql part and then echoing that back, but it gives me an error!!

 

<?php

$con = mysql_connect("localhost","root","");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

 

mysql_select_db("general", $con);

 

$var = @$_POST['search'];

$trimmed = trim($var);

if ($trimmed == "")

{

echo "<p>Please enter a search...</p>";

exit;

}

 

 

$query = "SELECT * FROM gjbusinesses where name like \"%$trimmed%\" OR description like \"%$trimmed%\";

 

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result))

{

echo $row['name'];

echo $row['phone'];

echo $row['address1];

echo $row['website'];

echo "Description:";

echo " ";

echo $row['description'];

echo "</strong>";

echo "<hr>";

echo "</hr>";

echo "<br />";

}

?>

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.