zetcoby Posted August 10, 2012 Share Posted August 10, 2012 hi guys, i wanna make a multilingual site that will store all the content in a DB for each language, i want it easy to edit for other persons using a admin panel, that is why i want to use a DB. The thing that i need to retrive data from the DB and insert it in to array. and in DB i wanted to do it like this: |++ID++|++++VAR++ |+++++++VAL+++++++| |++1++ |+++title+++ |++Welcome to my site++| |++2++ |++content++ |++some content+++++++| When i get this from the DB i want it to put it all in array like this: array( 'title' => 'Welcome to my site', 'content' => 'some content'); Link to comment https://forums.phpfreaks.com/topic/266903-generate-array-from-db/ Share on other sites More sharing options...
Barand Posted August 10, 2012 Share Posted August 10, 2012 try <?php $sql = "SELECT var, val FROM tablename"; $res = mysql_query($sql); $myarray = array(); while ($row = mysql_fetch_assoc($res)) { $myarray[$row['var']] = $row['val']; } ?> Link to comment https://forums.phpfreaks.com/topic/266903-generate-array-from-db/#findComment-1368326 Share on other sites More sharing options...
zetcoby Posted August 10, 2012 Author Share Posted August 10, 2012 thank you i will try it out right now Link to comment https://forums.phpfreaks.com/topic/266903-generate-array-from-db/#findComment-1368327 Share on other sites More sharing options...
zetcoby Posted August 10, 2012 Author Share Posted August 10, 2012 thank you very much ! ! ! it worked Link to comment https://forums.phpfreaks.com/topic/266903-generate-array-from-db/#findComment-1368328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.