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 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); ?> 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 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
Archived
This topic is now archived and is closed to further replies.