Hello.
I'm not sure how I can get around this, or what I am doing wrong, but I need some help.
I want to do an select query looking like this:
PHP Code:
SELECT venue, SUM( amount )
FROM IWD
WHERE venue = 'Foxy Hollow'
Unfortunately I need to have spaces in the names in these fields,
is there a way to get around it?
THe page I am making has an drop down menu, which is beeing populated by these names, and uppon selecting one of them, the above query will be issued.
THis is the full code that I am trying to use...
PHP Code:
<?php
if (isset($_POST['venue']))
{
$sel_venue = $_POST['venue'];
if ($sel_venue == "All venues")
{
unset($query);
echo "<div align=\"center\">";
echo "Total donations collected from each venue <br>";
echo "<table width=\"398\" height=\"29\" border=\"1\">";
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("waid") or die(mysql_error());
$query = "SELECT venue, SUM(amount) FROM IWD GROUP BY venue";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<th width=\"199\" height=\"25\" align=\"left\" valign=\"middle\" scope=\"col\">";
echo $row['venue'] . ":";
echo "</th>";
echo "<th align=\"left\" valign=\"middle\" scope=\"col\">";
echo "$" . $row['SUM(amount)'];
}
echo "</div></th></tr></table>";
mysql_close();
}
else
{
unset($query);
echo "Total donations collected from ";
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("waid") or die(mysql_error());
$query = "SELECT venue, SUM(amount) FROM IWD WHERE venue='$sel_venue'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "<div align=\"center\">";
echo "<table width=\"398\" height=\"29\" border=\"1\">";
echo "<tr>";
echo "<th width=\"199\" height=\"25\" align=\"left\" valign=\"middle\" scope=\"col\">";
echo $sel_venue . ":";
echo "</th>";
echo "<th align=\"left\" valign=\"middle\" scope=\"col\">";
echo "$" . $row['SUM(amount)'];
}
echo "</div></th></tr></table>";
mysql_close();
}
}
?>
Everything else is working on the page.. except this. :/