Jiraiya Posted November 25, 2008 Share Posted November 25, 2008 <table border="1"> <tr> <th>Villag</th> <th>Health</th> <th>Skill</th> <th>Current Hokage</th> </tr> <?php // includes $host = "localhost"; $user = "username"; $pass = "password"; $db = "databasename"; // open database connection $connection = mysql_connect(localhost, username, password) or die ("Unable to connect!"); // select database mysql_select_db(members) or die ("Unable to select database!"); // generate and execute query $query = "SELECT * FROM townranks ORDER BY skill DESC"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print article titles while($row = mysql_fetch_object($result)) { ?> <tr> <td><?php echo $row->townname; ?></td> <td><?php echo $row->hp; ?></td> <td><?php echo $row->sk; ?></td> <td><?php echo $row->kage; ?></td> </tr> <?php } } // if no records present // display message else { ?> <p>No data available</p> <?php } // close database connection mysql_close($connection); ?> </table> Link to comment https://forums.phpfreaks.com/topic/134208-solved-im-not-sure-whats-wrong-with-this-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.