Jump to content

list records from mysql database


benniss

Recommended Posts

I have inherited a site written using PHP. I am new to this and have found that part of the code doesn't do was it is meant to. The code is meant to pull teams from the mysql database and order them by team name. However the only entries that are displayed are those belonging to the first team name no others display. ??? Could someone tell me what is wrong with the code. The code before and after this works ok. Thanks in advance.

 

if($eventtype=='Team') {?>

<table class="dsR52" border="0" cellspacing="0" cellpadding="4">
<tr>
  <td class="text" width="200">
   <div align="left">Name</div>
  </td>
  <td class="text dsR28">Team</td>
  <td class="text dsR51">School</td>
</tr>
</table>

<?php

include ('../config/connector.php');
$query="SELECT * from entries where eventcode='$eventcode' and school='$schoolname' group by 'eventteam'";
$query_result = mysql_query ($query);
$num_records = @mysql_num_rows ($query_result);
$result = @mysql_query ($query);
if ($num_records > 0) {

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

$subeventteam=$row[5];
$subeventcode=$row[1]; ?><?php

include ('../config.php');
$querylist="SELECT * from entries where eventcode='$subeventcode' and eventteam='$subeventteam'"; 
$resultlist = @mysql_query ($querylist);
$num_recordlist = @mysql_num_rows ($resultlist);

while ($row3 = mysql_fetch_array($resultlist, MYSQL_NUM)) {

$studentname=$row3[8];
$eventteam=$row3[5];
$school=$row3[6]; ?>
<table class="dsR49" border="0" cellspacing="0" cellpadding="4">
<tr>
  <td class="text" width="200"><?php echo $studentname;?></td>
  <td class="text"><?php echo $eventteam;?>
  
<?php
if ($num_recordlist>$max) { echo "<font color='red'>(".$num_recordlist.")</font>"; } 
elseif ($num_recordlist<$min) { echo "<font color='red'>(".$num_recordlist.")</font>"; } 
else { echo "<font color='green'> (".$num_recordlist.")</font>"; }
?>

  </td>
  <td class="text dsR51"><?php echo $school; ?></td>
</tr>
</table>

<?php }
echo '<hr noshade="noshade" size="1" width="100%" />';?><?php }}else{?>
<p></p>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
  <td class="text"><?php echo 'There are NO entries for event '.$eventcode;?></td>
</tr>
</table>
<?php }?><?php}else

Link to comment
https://forums.phpfreaks.com/topic/121523-list-records-from-mysql-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.