I have to create a multiple alternating rows that contain different sets of data from different text documents. I can read text files okay I just cant figure out how I would do the alternating rows using the different queries in one html table.
I have thought about storing the data in a database, might this be a better way to go rather than reading in a text file every time the page loads?
What other ways could I achieve the output, I have currently looked at a previous thread Selecting alternating records from two tables but it didn't seem applicable due to it using a database to produce the results.
Keep a record of which line you're processing and use the modulus operator:
$LineNumber = 1;
while ()
{
if (($LineNumber % 2) == 1) // Is odd
$SecondaryTable .= "<td>I feel odd</td>";
else
$PrimaryTable .= "<td>hello</td>";
$LineNumber++;
}
// ... Finish off the tables here
echo $PrimaryTable;
echo $SecondaryTable;