Hello, I’ve been sitting trying to load data from a database into a table, it’s working but I just think the code is cluttering… Is there a shorter way to do it?
My code is following:
<?php
include('Dataconnection.php');
$connect = mysql_connect($host,$username,$password) or die('<p class="error">Unable to connect to the database server at this time.</p>');
mysql_select_db($database,$connect) or die('<p class="error">Unable to connect to the database at this time.</p>');
$query = "SELECT MemberID, FirstName, MiddleName, LastName FROM Golf_Member;";
$result = @mysql_query("$query") or die('<p class="error">There was an unexpected error grabbing shouts from the database.</p>');
?>
<html>
<body>
<table width="400" border="1">
<tr>
<th>Member ID</th>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
</tr>
<?
while ($row = mysql_fetch_assoc($result)) {
$MemberID = stripslashes($row['MemberID']);
$FirstName = stripslashes($row['FirstName']);
$MiddleName = stripslashes($row['MiddleName']);
$LastName = stripslashes($row['LastName']);
$repeater = '<td>'.$MemberID.'</td><td>'.$FirstName.'</td><td>'.$MiddleName.'</td><td>'.$LastName.'</td>';
echo('<tr>'.$repeater.'</tr>');
}
?>
</table>
</body>
</html>