I would like to create a table based on exploded content of a text file.
My text file contains information about users stored like this:
u0001:Omi Wan Kenomi:123456-12-1234:female:engaged:private sector:ddsfsfsdfsd:603-78860409:6015-2343444:omi.beckett@gmail.com:omiwan:dingo
u0002:Jason:334323-32-2323:male:married:private sector:dfsdfsdfsdf:603-42342342:6015-2321312:jason@gmail.com:jasonlim:dingo1234
u0003:Jina:443342-34-4434:female:engaged:government sector:BLAH BLAH BLAH:603-34334353:6012-7564938:jinadesus@yahoo.com:jina1234:dingo1234
u0004:Gail:432424-34-3242:male:single:private sector:Hell's Kitchen:603-32423423:6015-2432423:gail@gmail.com:gail1234:dingo1234
u0005:Deana Zafir:434435-35-3564:female:single:student:Melbourne Uni:603-44442345:6015-5356343:deanazafir@hotmail.com:Deana1234:dingo1234
To create a table within echo in php, I tried this code, but it wont work, the data displayed in the table is simply:
UserID : .Array[0].
Name : .Array[1]. IC : .Array[2]. Name : .Array[]. //as you can see, it's in some kind of format but not table.
Here's the code:
$facename= $_SESSION["facename"];
$UserInfo = file('datatext/users.txt');
echo "<table>";
foreach($UserInfo as $tag => $info)
{
$user[$tag] = explode(":",$info);
}
for($i=0;$i<=count($info);$i++)
{
if($user[$i][10] == $facename)
{
echo "<tr>";
echo "<td> UserID </td>";
echo "<td> : </td>";
echo "<td> .$user[$i][0].</td>";
echo "</tr>";
echo "</table>";
echo "<tr>";
echo "<td> Name </td>";
echo "<td> : </td>";
echo "<td> .$user[$i][1].</td>";
echo "</tr>";
echo "</table>";
echo "<tr>";
echo "<td> IC </td>";
echo "<td> : </td>";
echo "<td> .$user[$i][2].</td>";
echo "</tr>";
echo "</table>";
echo "<tr>";
echo "<td> Name </td>";
echo "<td> : </td>";
echo "<td> .$user[$i][].</td>";
echo "</tr>";
echo "</table>";
}
}
echo "</table>";
?>
However, when i simply echo the exploded array like this:
echo $user[$i][0];
echo $user[$i][1];
echo $user[$i][2];
echo $user[$i][3];
echo $user[$i][4];
echo $user[$i][5];
echo $user[$i][6];
echo $user[$i][7];
echo $user[$i][8];
echo $user[$i][9];
echo $user[$i][10];
echo $user[$i][11];
it works just fine, but the data is printed out in one long string.
I would like to know what I'm doing wrong, thank you :)