so this is what I have so far.
$query = mysql_query("SELECT * FROM tablename ORDER BY id");
while($r = mysql_fetch_array($query)){
extract($r);
echo $variables;
}
The error I get cause of above reason
Notice: Undefined variable: variables in
I've got honestly no idea how to do it ._ .
You should use fetch_assoc()
since it returns an associative array with the names and values of the rows. This would allow extract()
to generate the correct symbol names and therefor if there is a column called variables
the variable $variables
would exist.
A more common approach is just to access the data by $r['columnname'];
. Note that I updated your code with mysqli
functions (since mysql_*
is not so good..).
$query = $DB->query("SELECT * FROM tablename ORDER BY id");
while($r = $query->fetch_assoc()){
extract($r);
echo $variables;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.