edd12345678 Posted March 24, 2012 Share Posted March 24, 2012 Hi everyone, Hope someone can help. Does anyone know why this is nor displaying any data? $qry = mysql_query("select * from product"); $data = array(); while($row = mysql_fetch_array($qry)){ $productName[] =$row['productName']; // Item name } for($i=0;$i<mysql_num_rows($row);$i++) { $data = $productName[$i]; } return $data; Thanks in advance Edd Quote Link to comment https://forums.phpfreaks.com/topic/259643-adding-sql-data-to-an-php-array/ Share on other sites More sharing options...
litebearer Posted March 24, 2012 Share Posted March 24, 2012 Nowhere in that code are you telling it to display the info try... $qry = mysql_query("select * from product"); while($row = mysql_fetch_array($qry)){ echo $row['productName'] . "<br />; } Quote Link to comment https://forums.phpfreaks.com/topic/259643-adding-sql-data-to-an-php-array/#findComment-1330787 Share on other sites More sharing options...
cpd Posted March 24, 2012 Share Posted March 24, 2012 If your trying to put the data retrieved from the database into an array do the following. $qry = mysql_query("select * from product"); $data = array(); while($row = mysql_fetch_array($qry)){ $data[] = $row; } var_dump($data); Quote Link to comment https://forums.phpfreaks.com/topic/259643-adding-sql-data-to-an-php-array/#findComment-1330808 Share on other sites More sharing options...
edd12345678 Posted March 24, 2012 Author Share Posted March 24, 2012 Thanks CPD thats what I was looking for. Quote Link to comment https://forums.phpfreaks.com/topic/259643-adding-sql-data-to-an-php-array/#findComment-1330820 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.