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. Quote Link to comment 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 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.