i am fetching time from mysql_db below is my code...
$sql="SELECT * from employee_timings where emp_timing_date='$date'";
$query=mysql_query($sql);
$array=array();
while ($result=mysql_fetch_array($query)) {
# code...
$emp_starting_time=$result['emp_in_time'];
}
below is my table from which i am fetching the values...the issue is it gives me result in following format 11:00:0014:00:00 and when i echo this
echo $emp_starting_time[0];
it outputs the first character of first time i.e 1 and second time i.e 1 what i want is that whenever i echo
$emp_Starting_time[0]
it should display the whole 1st starting_time which is 11:00:00 kindly tell me how to achieve that
You give $emp_starting_time
variable the value $result['emp_in_time'];
. It contains the result you are looking for in a string
format. When you write echo $emp_starting_time[0];
, it returns you the fist charracter of this string. Try echo $emp_starting_time;
UPDATE
You can create an array outside of the loop and then push in it each value:
$array=array();
while ($result=mysql_fetch_array($query)) {
# code...
array_push($array, $result['emp_in_time']);
}