PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Background: ok so i would like to collect data from students of their information and also their class scheldules.
Problem: I managed to display everything perfectly. The only problem is displaying the scheldules in a decent viewable way. If anyone knows a better way to display class scheldules please let me know.
^ this is what I have so far that actually displays data from the database
<?PHP
$query = "SELECT * FROM _app ORDER BY id ";
$result = mysql_query($query) or die ("Query failed");
//let's get the number of rows in our result so we can use it in a for loop
$numofrows = mysql_num_rows($result);
?>
<?PHP
echo "<TABLE BORDER=\"1\" cellpadding=\"3\" >\n";
echo "<TR bgcolor=\"lightgreen\"><TD>ID:</TD><TD>IP Address:</TD><TD>Date:</TD><TD>Name:</TD><TD>Birthday:</TD><TD>Class Of:</TD><TD>Shirt Size:</TD><TD>GPA:</TD><TD>Periods:</TD><TD>Subject:</TD><TD>Teacher:</TD><TD>Room:</TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR bgcolor=\"lightblue\">\n";
} else { //if there isn't a remainder we will do the else
echo "<TR bgcolor=\"white\">\n";
}
echo "<TD>".$row['id']."</TD><TD>".$row['ip']."</TD><TD>".$row['date']."</TD><TD>".$row['fname']." ".$row['lname']."</TD><TD>".$row['bday']."</TD><TD>".$row['class']."</TD><TD>".$row['shirt']."</TD><TD>".$row['gpa']."</TD><TD>".$row['sdfsfd']."</TD></Tr>\n";
echo "</TR>\n";
}
//now let's close the table and be done with it
echo "</TABLE>\n";
?>
I'm having problem displaying it so that each ID person is displaying their full scheldule routinely one after another
because of the volume of extra data, I'd perform two seperate queries. One gets the people, the next get's all the period information associated with those people. Cache the results from the period information into an array. I'd use a nested loop, the outside runs over the people as they are returnedm while the inside counts to eight, pulling out associated the period for that person as it goes.
your reply sounded kind of complicated because i'm just begining to learn mysql and php. but I will google them out and try to learn to try them out....
otherwise could you possibily explain how the ECHO is used correctly to utilize html in php files?
cause i understand you begin html by echo "<br>\n"
but i don't understand if you have to repeat this step for EVERY new line of html or can you quote an entire block of html or how specificly does the ECHO use.
cause i think thats one of the problems i had with trying to figure out the layout.