Jump to content

Multiple Loops Need Separated


Xtremer360

Recommended Posts

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.

 

<?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>';

}
}

?> 

Link to comment
Share on other sites

<?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";

$r = mysql_query($query);
$n = mysql_num_rows($r);

if ($n == 0){
//output for no records...
echo '</body></html>';
exit();
}

// 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>';

}


?> 

 

???

Link to comment
Share on other sites

<?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 matches";

$r = mysql_query($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>';

$q = "SELECT * FROM shows WHERE id = '{$row['showid']}' ORDER BY id DESC";
$res = mysql_query($q);


while ($arr = mysql_fetch_array($res)){

print '<center>'.$arr['matchtype'].'</center>';
print '<center>'.$arr['vs1'].' vs. '.$arr['vs2'].'</center>';

}}


?> 

Like that ???

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.