benluke Posted September 14, 2006 Share Posted September 14, 2006 Hi,Going back sometime now and after posting on php freaks you helped me out with the following code (much appreciated)[code]<?php $sql = "SELECT knowledge_1 knowledge_2 knowledge_3 knowledge_4 knowledge_5 knowledge_6 knowledge_7 knowledge_8 knowledge_9 knowledge_10 knowledge_11 knowledge_12 knowledge_13 knowledge_14 FROM HS31 WHERE userid = $userid LIMIT 1"; if ($result = mysql_query($sql)) { $row = mysql_fetch_assoc($result); $array = array(); $array = unserialize($row['knowledge_1']); print_r($array); } else { echo "there was a problem"; }?>[/code]Which displays[code]Array ( [0] => A [1] => B [2] => C [3] => D )[/code]My question is this.What do i need to add / change so that it displays every array from each table row?Benluke Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted September 14, 2006 Share Posted September 14, 2006 probably just [code]SELECT *[/code]rather than all of the fieldsthen use a while loop to get each row and probably an explode function to echo each array so:[code]$sql=mysql_query("SELECT * FROM HS31");echo 'Array :<br>';while ($row=mysql_fetch_array($sql)){foreach ($row as $id=> $v) { echo $id'. => '.$v.'<br>'; }}[/code]Not tested that, but think it'll work Quote Link to comment Share on other sites More sharing options...
benluke Posted September 14, 2006 Author Share Posted September 14, 2006 Its giving me the following error:[code]Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/n/v/nvq/public_html/nvq/hs31/knowledge_display.php on line 29[/code]Thanks for your help gerkintrigg.Benluke Quote Link to comment 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.