I want to show the array, after array[0] has shown, show next data , loop to do that before have shown all data in database. e.g:
Array (
[0] => Array (
[ID] => 1 [name] => peter [time] = >1:00
)
[1] => Array (
[ID] =>2 [name]=> merry [time]=>3:00
)
...etc
I wish that:
-------------- |id|name |time|
-------------- |1 |peter|1:00|
-------------- |2 |merry|3:00|
-------------- |..|.....|.:..|
but the real is just only show array[0] . like that:
-------------- |id|name |time|
-------------- |1 |peter|1:00|
---------------
Can you tell me how to improve that and correct that?
$sql = "SELECT * FROM mytable";
$result = mysqli_query($conn, $sql);
$datas = array();
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result)){
$datas[] = $row;
}
}
$result = $conn->query($sql);
$x = 0;
$a = $datas[$x];
if($a = array())
{
echo "";
}
else
{
foreach($datas[$x] as $data){
echo $data."<td>"."<br>";
$x++;
}
}
if($a = array())??=assign a value==test a variable for equality$result = $conn->query($sql);after your first IF, you never make use of the reault of that query and it has aleady been run and saved into an array??