Jump to content

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

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.