Re: WAHT is my error???
| From: | Justin Patrin | Date: | Fri, 20 Aug 2004 19:46:32 +0000 |
| Subject: | Re: WAHT is my error??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194367@lists.php.net to get a copy of this message | ||
On Fri, 20 Aug 2004 19:34:51 +0100, Andre <andre_caridade@sapo.pt> wrote:
>
> Inside of one ARRAY can I make one WHILE
>
> function tabelas($tabela_tipo){
> $sql = mysql_query("SELECT * FROM ".$tabela_tipo."_credito ORDER BY
> ".$tabela_tipo."_ordenar");
> $return = "<select name=\"tabelas\"
> class=\"textblack\">\n";
> $tabela_array = array("".
No, you can't do such a thing. First of all, array() is a language
construct and creates an array from values passed into it. Second,
you're using period (.) here...what exactly are you trying to do?
Perhaps you should try:
$tablea_array = array();
> while($registo = mysql_fetch_array($sql)){
> array ("".$registo[0]."",
*WHY* are you concatenating a value to two empty strings? This
effectively changes the type of the variable to a string, but since
it's coming from the DB it's already a string. And besides which, it
very rarely matters to PHP whether something is a string or a number,
it will convert between them automatically.
> "".$registo[0]." ".$registo[0]."");
Maybe you mean to do:
$tablea_array[] = array ($registo[0], $registo[0].' '.$registo[0]);
> }.""
And remove the ."" here.
> foreach($tabela_array as $subarray) {
> list($num, $text) = $subarray;
> $return .= "<option value=\"$num\"
> selected>$text</option>\n";
> }
> $return .= "</select>\n";
> return $return;
> }
>
You really need to go back and run through some PHP tutorials, it
seems you don't really understand the language.
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--