Jump to content

[SOLVED] Not Getting Complete Data In Array


shan.devlop

Recommended Posts

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

 

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);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.