Re: php/msql
| From: | Fabien ILLIDE | Date: | Sat, 19 Jan 2002 01:58:24 +0000 |
| Subject: | Re: php/msql | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15981@lists.php.net to get a copy of this message | ||
Mike wrote:
Hi, Hi Mike
I have the following code: while ($row = mysql_fetch_array($result)) { echo "<tr><td>".$row[0]."</td>\n"; echo "<td>".$row[1]."</td>\n"; $formatted=sprintf("$%s",$row[2]); echo "<td>" $formatted " </td></tr><br>"; } I get an error in the last line where I want to put $formatted into the last cell of a table if I // echo $formatted without the HTML tags it puts it at the top of the page. Ok Well have you checked thant you have a <table> at top and </table> at bottom of the code you've send us ?
The error is : Parse error: parse error, expecting ','' or ';''
Ok. I think it's cause you missed the . or , before and after $formatted.
Like at the second line : "blablabla".$something."blablabla";
It's for echoing the text, then the value of the variable, then text agin.
It works with both . and ,
Try to do : echo "<td>",$formatted,'</td></tr><br>";
also: what does the "\n" mean at the end of the html tags? It's to break a line *in the source code* created by php (try to look the source of the page by your browser and see the diffrence)
I am new to PHP and have no seen that before. It's juste to produce "nice looking" source html code.
Thanks. Mike De rien ;o)Tell us how it works ;-) Bye Fabien ILLIDE