Jump to content

Selecting from Database mySQL


FloridaNutz

Recommended Posts

Ok, I have a page where I can edit the entries I have and it works fine.  I think the problem is that there is multiple entries that will have UCF as their area...  I want the sql to go through and only display the bars in that area

[code]
$idm = $_GET[id];
$sql = "SELECT * FROM $table_name WHERE UCF_id=$idm";[/code]

but when I try to bring up only a certain area of bars I get an error

[code]
$barAreaM = "$_GET[barMenu]";
$sql = "SELECT * FROM $table_name WHERE barName=$barAreaM";[/code]

Unknown column 'UCF' in 'where clause'

Link to comment
Share on other sites

[code]<?

//access the database
$barAreaM = "$_GET[barMenu]";

$db_name = "cfuf";
$table_name = "dso_bars";

$connection = @mysql_connect("+++", "+++", "+++")
or die(mysql_error());

$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$sql = "SELECT * FROM $table_name WHERE barName=$barAreaM";

$result = @mysql_query($sql, $connection) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$barArea = $row['barArea'];
$UCF_id = $row['UCF_id'];
$barName = stripslashes($row['barName']);
$barPhone = stripslashes($row['barPhone']);
$barAddress = stripslashes($row['barAddress']);
$barVIP = stripslashes($row['barVIP']);
$barCity = stripslashes($row['barCity']);
$barZip = stripslashes($row['barZip']);
$barComments = stripslashes($row['barComments']);
$barKey = stripslashes($row['barKey']);
$barKey = unserialize($row['barKey']);
$view = '<a href="../bar/do_viewbar.php?id='. $UCF_id. '">
<img src="../images/search.png" width="16" height="16" border="0"></a>';
$edit = '<a href="../bar/edit_bar.php?id='. $UCF_id. '">
<img src="../images/edit.png" width="16" height="16" border="0"></a>';
$delete = '<a href="../bar/delete_confirm.php?id='. $UCF_id. '"><img src="../images/delete.png" width="16" height="16" border="0"></a>';
$display_block .= "<p><strong>$barName:</strong> $barAddress, $barCity $barZip<br>
  Phone: $barPhone  VIP Line: $barVIP $view $edit $delete</p><br>
    <strong>Bar Key:</strong> $barKey[0] $barKey[1] $barKey[2] $barKey[3] $barKey[4] $barKey[5] $barKey[6] $barKey[7] $barKey[8]<br>
$barKey[9] $barKey[10] $barKey[11] $barKey[12]<hr />";
} ?>

<html>
<head>
<title>View Bars</title>
</head>
<body>
<p><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><img src="../images/admin_head.gif" width="380" height="51" /></font><a href="../admin_main.html"><img src="../images/Menu.png" width="94" height="32" border="0"></a></p>
<hr />
<span class="Heading"><strong class="Heading"><font color="#B5BFCC" size="6" face="Verdana, Arial, Helvetica, sans-serif">Orlando </font><font color="#B5BFCC" size="6" face="Verdana, Arial, Helvetica, sans-serif">Area<br>
</font></strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><br>
<br>
<? echo "$display_block"; ?></font>
</body>
</html>

[/code]

This is how I would get all the bars before

[code]
$sql = "SELECT * FROM $table_name ORDER BY UCF_id";[/code]
Link to comment
Share on other sites

I don't understand how you get an unknown column UCF from a query looking for the column barName.

Try restructuring your code - and remove the @ symbols so you see errors.

[code]$barAreaM = $_GET['barMenu'];
$sql = "SELECT * FROM $table_name WHERE barName = '$barAreaM' ";
$result = mysql_query($sql) or die("Error: ". mysql_error(). " with query ". $sql); // helpful error message[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.