Re: howto build a string...
| From: | Matt McClanahan | Date: | Fri, 28 Jul 2000 05:09:36 +0000 |
| Subject: | Re: howto build a string... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-8712@lists.php.net to get a copy of this message | ||
On Fri, 28 Jul 2000, Sam Carleton wrote:
> I would like to build a string within a case statement, but the result
> is always zero. Here is the code, what am I missing?
>
> $select = "SELECT * FROM bare_asin WHERE checked = 0";
> $select2 = "";
>
> if( isset($s) ) {
> switch($s) {
> case "A1":
> $select2 = $select + " ORDER BY asin ASC;";
> echo("<tr><td
> colspan='5'>A1=$select2</td></tr>");
> break;
> case "A2":
> $select2 = $select + " ORDER BY asin DESC;";
> echo("<tr><td
> colspan='5'>A2=$select2</td></tr>");
> break;
> default:
> $select2 = "SELECT * FROM bare_asin WHERE checked = 0";
> echo("<tr><td colspan='5'>$select2</td></tr>");
> }
>
> $select = $select2;
> }
>
> echo("<tr><td
> colspan='5'>\$select2=[$select2]</td></tr>");
> echo("<tr><td colspan='5'>$select</td></tr>");
You want to use . instead of + for your concatenation. Otherwise it tries
to actually add the value of the strings together, iirc.
> I would prefer to simply eliminate the $select2 variable.
Not difficult. You can say $select .= ' ORDER BY asin ASC;';
Matt