Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

If Else - select all drop down

Guest
Mar 19, 2008 Mar 19, 2008

Copy link to clipboard

Copied


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);
TOPICS
Server side applications

Views

297
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 20, 2008 Mar 20, 2008

Copy link to clipboard

Copied

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);
>
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 20, 2008 Mar 20, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 20, 2008 Mar 20, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 20, 2008 Mar 20, 2008

Copy link to clipboard

Copied

LATEST
how would that look?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines