Multiple Loops Need Separated

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!

Moderator: General Moderators

Post Reply
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Multiple Loops Need Separated

Post by CoolAsCarlito »

I have a while statement that has two loops but don't want them to be intertwined and need someones help telling me how to separate the two. Everything below belltime should be in it's own loop. But working with the curly braces and what not and I even tried sticking in an else i couldn't get the loops correct.

Code: Select all

 
<?php echo "<body bgcolor=\"black\" text=\"white\" link=\"red\" vlink=\"red\">"; 
 
require ('database.php');
 
print '<center><img src=/images/" . $row["showimage"] " height="125" width="500" border="1"></center>';
 
//Define the query
$query = "SELECT *, DATE_FORMAT(`date`, '%M %e, %Y') AS date FROM shows, matches WHERE matches.showid = shows.id";
 
if ($r = mysql_query ($query)){ // Run the query. 
 
// Retrieve and print every record
while ($row = mysql_fetch_array ($r)){
 
print '<center>Date: '.$row['date'].'</center>';
print '<center>Location: '.$row['location'].'</center>';
print '<center>Bell Time: '.$row['belltime'].'</center><br><br>';
print '<center>'.$row['matchtype'].'</center>';
print '<center>'.$row['vs1'].' vs. '.$row['vs2'].'</center>';
 
}
}
 
?> 
 
CoolAsCarlito
Forum Contributor
Posts: 192
Joined: Sat May 31, 2008 3:27 pm
Contact:

Re: Multiple Loops Need Separated

Post by CoolAsCarlito »

After realizing what I said I take all of that back. What I should do is simply just have matchtype and vs1 and vs2 part as the only thing in the loop. But when I took the date,location,belltime out of the loop it wouldn't display those values.
Post Reply