On Mon, Nov 24, 2003 at 09:42:30PM -0800, Joffrey Leevy wrote:
:
: Would appreciate in anyone can help me.
Some more code would be helpful.
: Let's say I do a query in php, eg. $query = "select
: shed from structure"; With the mysql_fetch_array
: function and a loop I could see all the values stored
: in the column, shed, using the command: echo $shed;
$query = "select shed from structure";
$result = mysql_query($query);
while (($row = mysql_fetch_array($result)) !== false)
{
echo $row['shed'];
}
: Let's say now that I am carrying over a variable from
: a form called $form where $form = shed. I can still
: say $query = "select $form from structure"; because
: $form = shed.
Try using more variables to make life a little easier to parse:
$colname = $_FORM['form']
$query = "select {$colname} from structure";
$result = mysql_query($query);
while (($row = mysql_fetch_array($result)) !== false)
{
echo $row[$colname];
}
: The problem I have now is with the strings and how do
: I see my column values.
Use better variable names. And avoid register_globals.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php