MySQL Forums
Forum List  »  PHP

Re: How do I make all columns line up in the same row?
Posted by: Peter Brawley
Date: March 14, 2006 02:45PM

What are you trying to accomplish with the asterisks at the ends of column names? They'll generate syntax errors.

Before trying a query in PHP--any query--test it in the mysql client to verify that it delivers precisely what you want.

Why the quotes around PHP function calls!?

$query = mysql_query($q);
$cols = mysql_num_fields($query);
while ($row = mysql_fetch_array($query)) {
$nextline = "";
for($i = 0; $i < $cols; $i++) {
// Use .= tather than += so PHP doesn't try to add numerics
$nextline .= $row[ $i ] . ($i < $cols ? ", " : "");
}
fwrite($fp,$nextline);
}

PB

Options: ReplyQuote


Subject
Written By
Posted
Re: How do I make all columns line up in the same row?
March 14, 2006 02:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.