Skip to main content
Participant
April 19, 2006
Question

Display Resuts Based on 2 drop down menus selection

  • April 19, 2006
  • 3 replies
  • 348 views
Hi All
I'm using Dreamweaver MX PHP/SQL
I want to display result of database based on the selection ot 2 drop down menu.
I've created a form with 2 drop down menu. first one is employer and the secod is program

I've created a recordset query in the advance mode. here is the SQL statement:

SELECT gradtbl.id, gradtbl.full_name, gradtbl.home_phone, gradtbl.mobile_phone, gradtbl.email
FROM careertbl, gradtbl
WHERE careertbl.emp_id = colname AND gradtbl.program = progdrp AND careertbl.student_id = gradtbl.id

colname and progdrp are Form variables. (I defined them in the varialbles section in the recordset box) as following
NAME Defaulf Value Run-time Value
progdrp 1 $HTTP_POST_VARS['program']
colname 1 $HTTP_POST_VARS['employer']

The problem is with the progdrp.... when I remove it and do the search based on the employer drp It works fine. But when I add the progdrp I got
Unknown column 'ABUS' in 'where clause' (ABUS is my selection)

Below is the generated code
mysql_select_db($database_grad, $grad);
$query_Recordset1 = sprintf("SELECT gradtbl.id, gradtbl.full_name, gradtbl.home_phone, gradtbl.mobile_phone, gradtbl.email FROM careertbl, gradtbl WHERE careertbl.emp_id = %s AND gradtbl.program = %s AND careertbl.student_id = gradtbl.id ", $colname_Recordset1,$progdrp_Recordset1);
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $grad) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

Can Any one help me in that
This topic has been closed for replies.

3 replies

BeshayerAuthor
Participant
April 19, 2006
Thanks the single quotes works
Participant
April 19, 2006
hi.

i dont use php so dont think i could help with that. but the unknown colum thing pops its head up in asp aswell. its when the value of a where statement isnt enclosed with '' the single lil line thing. "where column = value" should be "where column = 'value' "
Inspiring
April 19, 2006
If you are matching text fields in the SQL statement, you should have single
quotes round the parameters eg

$query_Recordset1 = sprintf("SELECT gradtbl.id, gradtbl.full_name,
gradtbl.home_phone, gradtbl.mobile_phone, gradtbl.email FROM careertbl,
gradtbl
WHERE careertbl.emp_id = %s AND gradtbl.program = %s AND
careertbl.student_id =
gradtbl.id ", $colname_Recordset1,$progdrp_Recordset1);

Should be

$query_Recordset1 = sprintf("SELECT gradtbl.id, gradtbl.full_name,
gradtbl.home_phone, gradtbl.mobile_phone, gradtbl.email FROM careertbl,
gradtbl
WHERE careertbl.emp_id = %s AND gradtbl.program = '%s' AND
careertbl.student_id =
gradtbl.id ", $colname_Recordset1,$progdrp_Recordset1);

Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.