want2php Posted November 1, 2009 Share Posted November 1, 2009 Very newbie here. My sql table: Table name: user_types - user_type_id = autoincrement - user_types = varchar with 4 records (Admin, User, Guest, Staff) how do i perform the query so that it displays the result into arrays, like: [1] => Admin [2] => User .... thanks for all your help. Link to comment https://forums.phpfreaks.com/topic/179813-sql-query-results-into-array/ Share on other sites More sharing options...
joel24 Posted November 1, 2009 Share Posted November 1, 2009 in the array [1] => Admin [2] => User is 1 the admin user_type_id? if so.. you'd have somthing like this $sql = @mysql_query("SELECT * FROM user_types"); while ($r = mysql_fetch_array($sql)) { $userTypes[$r['user_type_id']] = $r['user_types']; } then you'd have an array with $userTypes[1] = "Admin" $userTypes[2] = "User" etc Link to comment https://forums.phpfreaks.com/topic/179813-sql-query-results-into-array/#findComment-948632 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.