Forums
This topic is locked
RECORDSET HELP?
Posted 26 Apr 2006 23:54:12
1
has voted
26 Apr 2006 23:54:12 fiona gilmour posted:
Hi I've finally hanaged to get 3 drop down menus to work that change depending on what has been selected in the previous one. (using php and javascript). However I cant get the recordset right to then display the correct answers!
Heres what i've got; list boxes are names tab1, tab2, tab3 (subject, level, author)
I have made a recordset in the results page as follows:
SELECT *
FROM activity
WHERE SUBJECT = 'colname'
AND LEVEL = 'colname1'
AND author = 'colname2'
my variables are:
colname = $_POST['tab1']
colname1 = $_POST['tab2']
colname2 = $_POST['tab3']
problem is if a selection isn't made in one of the boxes the results page doesn't show anything (i'd like no selection to show everything). I'm new to all this and any help would be really appreciated.
Thanks x
Replies
Replied 27 Apr 2006 15:14:26
27 Apr 2006 15:14:26 Roddy Dairion replied:
Hope it helps
<pre id=code><font face=courier size=2 id=code>
$colname = $_POST['tab1'];
$colname1 = $_POST['tab2'];
$colname2 = $_POST['tab3'];
$select = "SELECT * FROM activity";
if ((isset($colname)) || (isset($colname1)) || (isset($colname2)))
{
$select.="where";
$select.=isset($colname) ? "colname = ". $colname : "";
if (isset($colname))
{
$AND = " and ";
}
$select.=(isset($colname1)) ? $AND ."colname1 = ". $colname1 : "";
if (isset($colname1))
{
$AND = " and ";
}
$select.=isset($colname2) ? $AND ."colname2 = ". $colname2 : "";
}
</font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code>
$colname = $_POST['tab1'];
$colname1 = $_POST['tab2'];
$colname2 = $_POST['tab3'];
$select = "SELECT * FROM activity";
if ((isset($colname)) || (isset($colname1)) || (isset($colname2)))
{
$select.="where";
$select.=isset($colname) ? "colname = ". $colname : "";
if (isset($colname))
{
$AND = " and ";
}
$select.=(isset($colname1)) ? $AND ."colname1 = ". $colname1 : "";
if (isset($colname1))
{
$AND = " and ";
}
$select.=isset($colname2) ? $AND ."colname2 = ". $colname2 : "";
}
</font id=code></pre id=code>
Replied 28 Apr 2006 18:40:43
28 Apr 2006 18:40:43 fiona gilmour replied:
thanks for that.
Its eventually working!
x
Its eventually working!
x