Hi, I'm using the following code to query my database table and display the data on a page:
//connect to the DB
include('db.php');
//set up query
$query = "SELECT * FROM clients,projprog WHERE clients.clientid = projprog.clientid AND clients.clientid = 8";
//run query
$result = mysql_query($query, $connection) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$date = $row['date'];
$postby = $row['postby'];
$subject = $row['subject'];
$post = $row['post'];
}
?>
<html>
<body>
<?php do { ?>
<table>
<tr><td><?php echo $date; ?></td><td><?php echo $postby; ?></td></tr>
<tr><td><?php echo $subject; ?></td></tr>
<tr><td><?php echo $post; ?></td></tr>
</table>
<?php
} while ($row = mysql_fetch_array($result));
?>
</body></html>
<?php mysql_free_result($result);?>
Although this works fine it only displays one row from my table - how do I get it to display all the rows I'm asking for?
Would I be right in thinking i have to use something like:
$totalRows = mysql_num_rows($result);
Any help much appreciated...
//connect to the DB
include('db.php');
//set up query
$query = "SELECT * FROM clients,projprog WHERE clients.clientid = projprog.clientid AND clients.clientid = 8";
//run query
$result = mysql_query($query, $connection) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$date = $row['date'];
$postby = $row['postby'];
$subject = $row['subject'];
$post = $row['post'];
}
?>
<html>
<body>
<?php do { ?>
<table>
<tr><td><?php echo $date; ?></td><td><?php echo $postby; ?></td></tr>
<tr><td><?php echo $subject; ?></td></tr>
<tr><td><?php echo $post; ?></td></tr>
</table>
<?php
} while ($row = mysql_fetch_array($result));
?>
</body></html>
<?php mysql_free_result($result);?>
Although this works fine it only displays one row from my table - how do I get it to display all the rows I'm asking for?
Would I be right in thinking i have to use something like:
$totalRows = mysql_num_rows($result);
Any help much appreciated...