Hi, newbie, so new I hope I can ask the question intelligently enough. I also hope I’m in the right forum [sql or php)
MySQL database has two tables;
tblnames > [clmid, clmnames]
tblpol > [clmDate, clmCategory, clmnames, clmComment]
My goal is: The user selects a category from a dropdown list, clicks a button & returns all rows of [tblpol.clmDate, tblnames.clmnames, tblpol.clmComment] data that match the user selection value $Category.
tblpol.clmnames contains only a names id so I don’t want to display that, I want to display the full text name which is stored in tblnames.clmnames I think I need a JOIN to do this. Here is my attempt which doesn’t work of course & I get the error “Unknown column ‘XYZ’ in ‘where clause’”
[php]$clmCategory = $_GET[‘clmCategory’];
$clmCategory = mysql_real_escape_string($clmCategory);
$query = “SELECT tblpol.clmDate, tblnames.clmnames, tblpol.clmComment
FROM tblpol
INNER JOIN tblnames ON (tblpol.clmnames = tblnames.clmnames)
WHERE clmCategory = $clmCategory”;
$qry_result = mysql_query($query) or die(mysql_error());
$display_string = “
$row[clmDate] | ”;$row[clmnames] | ”;$row[clmComment] | ”;