shan.devlop Posted October 11, 2007 Share Posted October 11, 2007 hi everyone i am working on a script to make schedule for different employee. i wrote this piece of code to get diff staffs name on interface. at this time i had two users but the code only shows one entry in final array that too the later one.. i want my array two show all enteries. here is the code $sql = tep_db_query(' SELECT * FROM `booking_loc`'); while ($res = mysql_fetch_array($sql, MYSQL_ASSOC)){ $array = array( 'loc' , $res[loc_id]); $loc = implode( $array); echo "loc: $loc</br>"; $array = array( 'event_id_staff_' , $res[staff_id]); $stf = implode( $array); $stf_name = $res[staff_name]; } $staff_db_name = array ($stf); print_r($staff_db_name); this outputs: Array ( [0] => event_id_staff_18 ) Please Help Thanks Quote Link to comment https://forums.phpfreaks.com/topic/72783-solved-not-getting-complete-data-in-array/ Share on other sites More sharing options...
trq Posted October 11, 2007 Share Posted October 11, 2007 You keep overiding your array with each loop. Try... <?php $sql = tep_db_query(' SELECT * FROM `booking_loc`'); while ($res = mysql_fetch_array($sql, MYSQL_ASSOC)){ $array[] = array( 'loc' , $res['loc_id']); $loc = implode( $array); echo "loc: $loc</br>"; $array[] = array( 'event_id_staff_' , $res['staff_id']); $stf[] = implode( $array); $stf_name = $res['staff_name']; } $staff_db_name = array ($stf); print_r($staff_db_name); ?> Quote Link to comment https://forums.phpfreaks.com/topic/72783-solved-not-getting-complete-data-in-array/#findComment-367057 Share on other sites More sharing options...
shan.devlop Posted October 11, 2007 Author Share Posted October 11, 2007 hey man didnt thought it will be so simple problem solved Thanks Quote Link to comment https://forums.phpfreaks.com/topic/72783-solved-not-getting-complete-data-in-array/#findComment-367059 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.