Skip to main content
March 19, 2008
Question

If Else - select all drop down

  • March 19, 2008
  • 4 replies
  • 317 views

PHP/MySQL
Form Post
Drop Down

I want to retrieve all results when users choose the defaulted drop down option of 'select all'.

How to I create the database query on the results page?

I attempted an if else statement, but this leaves the page blank. Would if else be the correct approach?... and if so, where is my syntax error?

if (isset($_POST['securityclearance']) == '' {
$colname_rs == "#";
}
else {
$colname_rs = "-1";
if (isset($_POST['id'])) {
$colname_rs = $_POST['id'];
}
mysql_select_db($database_connDB2, $connDB2);
$query_rs = sprintf("SELECT j* FROM X
WHERE id = %s", GetSQLValueString($colname_rs, "int"));
$rs = mysql_query($query_rs, $connDB2) or die(mysql_error());
$row_rs = mysql_fetch_assoc($rs);
$totalRows_rs = mysql_num_rows($rs);
This topic has been closed for replies.

4 replies

March 21, 2008
how would that look?
Inspiring
March 20, 2008
Yes

--
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com


"jsteinmann" <webforumsuser@macromedia.com> wrote in message
news:fru6b5$obe$1@forums.macromedia.com...
> In the case of this search, I have like 5-6 column variables, so I'm
> assuming I would need the if else on just the column params since I
> wouldn't want to create a new recordset for each item.

March 20, 2008
In the case of this search, I have like 5-6 column variables, so I'm assuming I would need the if else on just the column params since I wouldn't want to create a new recordset for each item.
Inspiring
March 20, 2008
Try changing just the SQL to something like this:

// if the id dropdown value DOES NOT equal all use this SQL
if ($_POST['id'] != 'all'){
$query_rs = sprintf("SELECT j* FROM X WHERE id = %s",
GetSQLValueString($colname_rs, "int"));
}
// if the id dropdown value DOES equal all use this SQL
else {
$query_rsActor = "SELECT j* FROM X";
}


--
Ken Ford
Adobe Community Expert - Dreamweaver
Fordwebs, LLC
http://www.fordwebs.com


"jsteinmann" <webforumsuser@macromedia.com> wrote in message
news:frqhsj$ol4$1@forums.macromedia.com...
> PHP/MySQL
> Form Post
> Drop Down
>
> I want to retrieve all results when users choose the defaulted drop down
> option of 'select all'.
>
> How to I create the database query on the results page?
>
> I attempted an if else statement, but this leaves the page blank. Would
> if
> else be the correct approach?... and if so, where is my syntax error?
>
> if (isset($_POST['securityclearance']) == '' {
> $colname_rs == "#";
> }
> else {
> $colname_rs = "-1";
> if (isset($_POST['id'])) {
> $colname_rs = $_POST['id'];
> }
> mysql_select_db($database_connDB2, $connDB2);
> $query_rs = sprintf("SELECT j* FROM X
> WHERE id = %s", GetSQLValueString($colname_rs, "int"));
> $rs = mysql_query($query_rs, $connDB2) or die(mysql_error());
> $row_rs = mysql_fetch_assoc($rs);
> $totalRows_rs = mysql_num_rows($rs);
>
>