PDA

View Full Version : extact variables


Dimava
Fri 14th Jun '02, 2:25pm
<?php
include("templates/header.htm");
require("admins/config.php");
require("global.php");
include("templates/index/index_start.php");

$front_page_news=$DB_site->query("SELECT id, name, date, username, description, source, image FROM news ORDER BY date DESC, id DESC LIMIT 5");
while( $row = $DB_site->fetch_array($front_page_news) ) {

$newdate2 = chunk_split($date, 2, '.');
$newdate = substr($newdate2, 0, strlen($newdate2)-1);
$description = substr($description, 0, 500);

include("templates/index/news_template.php");
}

include("templates/index/index_end.php");
include("templates/footer.htm");
?>


How Do I extract the variables within the loop

thanks

Dimava

Mark Hensler
Fri 14th Jun '02, 6:31pm
PHP Docs: extract() (http://www.php.net/manual/en/function.extract.php)

MartynJ
Fri 14th Jun '02, 6:42pm
Your sig doesn't work Mark.

Dimava
Fri 14th Jun '02, 11:42pm
$front_page_news=$DB_site->query("SELECT id, name, date, username, description, source, image FROM news ORDER BY date DESC, id DESC LIMIT 5");
while( $row = $DB_site->fetch_array($front_page_news) ) {

extract ($front_page_news);

print "$id, $name, $date, $username, $description, $source, $simage";


$newdate2 = chunk_split($date, 2, '.');
$newdate = substr($newdate2, 0, strlen($newdate2)-1);
$description = substr($description, 0, 500);

include("templates/index/news_template.php");
}


I get this error:

Warning: extract() expects first argument to be an array in /home/virtual/site3/fst/var/www/html/test23/index.php on line 24

line24 is the line that says "extract ($front_page_news);"

-Dimava

Gramphos
Sat 15th Jun '02, 5:59pm
Change it to
extract ($row);

Dimava
Sat 15th Jun '02, 6:39pm
thanks, thats just what I needed