Ok guys I need some help... I am having a similar issue let me tell you a little bit of what I am wanting to do.
I have a MySQL database with my data in it that I want on my web page.
What I need is a table with all of the data that is in that database listed and above it I want drop downs people can select from to filter the table to display just what they are looking for. With each drop down options coming from my data base and depending on what the first drop down had selected...
What I have so far on the MAIN page is this.
<?
$sql="SELECT id, bar_name FROM barlist";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["id"];
$thing=$row["bar_name"];
$options.="<OPTION VALUE=\"$id\">$bar_name</option>";
}
?>
<SELECT NAME=id>
<OPTION VALUE=0>Choose
<? echo $options?>
</SELECT>
and on the data base connection page I have this
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
<?php
$q=$_GET["q"];
$con = mysql_connect('DATABASE', 'USER', 'PASSWORD');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$sql="SELECT * FROM bar WHERE id = '".$q."'";
$result = mysql_query($sql);
echo "<table border='1'>
<tr>
<th>Bar Name</th>
<th>Address</th>
<th>Time they open</th>
<th>Time they close</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['bar_name'] . "</td>";
echo "<td>" . $row['address'] . "</td>";
echo "<td>" . $row['bar_open'] . "</td>";
echo "<td>" . $row['bar_close'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
</html>
The above code gives me the following errors on the main page
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/40/8248640/html/murfreesboro.php on line 96
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/content/40/8248640/html/murfreesboro.php on line 96
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/content/40/8248640/html/murfreesboro.php on line 100
I know a lot of reading I am sorry if you guys could help me out I would greatly appreciate it!