Im trying to get one of the coloumns in my table to output the number of presentations related to a meeting using the COUNT(). It works the only problem is that i want it to count for every meeting entry in the database. Because i use a while loop the loop continues and doesn’t end where before i put in this feature count() it outputed the data in the database and then finished. Any ideas?
[code=php]<?php
require_once(‘../../../classes/database.class.php’);
$database = new database();
$link_id = $database->database_connection();
$query = “select * from epc_meetings order by meetingid desc”;
$result = mysql_query($query) or die(mysql_error());
$total_rows = mysql_num_rows($result);
$file = mysql_fetch_array($result);
if (!$result)
{
print ‘There was a database error when executing’;
print mysql_error();
exit;
}
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>EPC Website Administration: Meetings</title>
<link href=”../../css/epc_admin.css” rel=”stylesheet” type=”text/css” />
<script language=”JavaScript” type=”text/JavaScript”>
<!–
function BRB_PHP_DelWithCon(deletepage_url,field_name,field_value,messagetext) { //v1.0 – Deletes a record with confirmation
if (confirm(messagetext)==1){
location.href = eval(‘”‘+deletepage_url+’?’+field_name+’=’+field_value+'”‘);
}
}
//–>
</script>
<script src=”../../includes/sorttable.js”></script>
</head>
<body>
<div id=”heading”>
<h1><a href=”../index.php”>Website Adminstration</a>: Meetings</h1>
<img src=”../../images/!genric/epc2.jpg” width=”305″ height=”54″ />
<div class=”clear”></div>
</div>
<div id=”main”>
<p>[<a href=”upload.php”>Add a new meeting</a>]</p>
<?php if($total_rows == 0)
{ ?>
<p>There are currently no meeting entries in the database</p>
<?
}
if ($total_rows > 0) { ?>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ class=”indexTable sortable” id=”indexTable”>
<tr>
<th scope=”col”>Event</th>
<th scope=”col”>Location</th>
<th scope=”col”>Year</th>
<th scope=”col”>Presentations</th>
<th colspan=”3″>Action</th>
</tr>
<?php do { ?>
<tr>
<td><?php print $file[‘event’]; ?></td>
<td><?php print $file[‘location’]; ?></td>
<td><?php print $file[‘year’]; ?></td>
<td>
<?php
$id = $file[‘meetingid’];
$database = new database();
$link_id = $database->database_connection();
$query = “select * from epc_meeting_presentations where meetingid = ‘$id'”;
$result = mysql_query($query) or die(mysql_error());
if (!$result)
{
print ‘There was a database error when executing’;
print mysql_error();
exit;
}
echo count($result);
?>
</td>
<td class=”narrow”><?php print ‘<a href=”edit_file.php?id=’.$file[‘meetingid’].'”>Edit</a>’; ?></td>
<td class=”narrow”><a href=”javascript:BRB_PHP_DelWithCon(‘delete.php’, ‘meetingid’,<?php echo $file[‘meetingid’];?>, ‘Are you sure you want to delete this entry?’);”>Delete</a></td>
<td class=”narrow”><?php print ‘<a href=”presentations/index.php?id=’.$file[‘meetingid’].'”>View Presentations</a>’; ?></td>
</tr>
<?php } while ($file = mysql_fetch_array($result)); ?>
</table>
<?php } ?>
<p> </p>
</div>
</body>
</html>