overlordofevil Posted November 6, 2008 Share Posted November 6, 2008 hello all, I am a bit stuck on this. I am trying to pull data from a mysql table to display on a web page and I want to separate the data by the "type" of item it is. So my table consists of the following elements. skillName skillType Fcost Tcost Rcost Scost prereq now what I want to do is pull the data and put it all into an array called skills, then another arrays in it called type. Simple enough on what I want to do but I can't figure it out so any hints on what to look at to try and set this up. I'm not looking for someone to do the work just point me to the right area to find the info and figure it out. Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/131717-solved-creating-a-multidimensional-array-from-mysql-data/ Share on other sites More sharing options...
Barand Posted November 7, 2008 Share Posted November 7, 2008 try <?php $sql = "SELECT skillName, skillType, Fcost, Tcost, Rcost, Scost, prereq FROM tablename"; $res = mysql_query($sql); while ($row = mysql_fetch_assoc($res)) { $skills[$row['skillName']][] = $row; $types[$row['skillType']][] = $row; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/131717-solved-creating-a-multidimensional-array-from-mysql-data/#findComment-684212 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.