Problem with fetching table to array
Posted
by jasmine
on Stack Overflow
See other posts from Stack Overflow
or by jasmine
Published on 2010-05-30T09:21:38Z
Indexed on
2010/05/30
9:32 UTC
Read the original article
Hit count: 126
php
I have writed this function:
function news_array()
{
$sql = "SELECT * FROM content WHERE home=1";
$query = mysql_query($sql);
$i = 0;
while($row = mysql_fetch_array($query)){
$row_array[$i] =
array(
TITLE => $row['title'],
ABSTRACTT => $row['abstract'],
BODY => $row['body'],
ID => $row['conID']
);
$i++;
}
return $row_array;
}
When using this function like this:
<?php
$row_array = news_array();
for($i = 0 ; $i < count($row_array) ; $i++){
echo $row_array[$i][TITLE];
}
?>
There no output in html. What is wrong in my function? Thanks in advance
© Stack Overflow or respective owner