Is there a better way to write this?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there everyone,

I'm re-writing the messageboard that my boss uses, and I wanted to know if there's a cleaner way to do the below code.  The first bit gets the name of the forum by the ID sent from the previous page to display the forum name, then the second bit gets some of the info for the message listing.  The forum name is NOT stored in the actual messages table, it's in the forum index table I created.

The code I use is:

<?   

include("../../connectionstart.php");

$query = "SELECT * FROM forums WHERE ForumID = '$ForumID' ORDER BY ForumID ASC";

$sql_result = mysql_query($query,$connection)
 or die("Couldn't execute query.");

while ($row = mysql_fetch_array($sql_result)) {

 $Forum = $row["Forum"];
 
};

$query = "SELECT * FROM forummessages WHERE ForumID = '$ForumID' ORDER BY ForumID ASC";

$sql_result = mysql_query($query,$connection)
 or die("Couldn't execute query.");

while ($row = mysql_fetch_array($sql_result)) {

 $id = $row["id"];
 $MessageID = $row["MessageID"];
 $ForumID = $row["ForumID"];
 $subject = $row["subject"];

};
?>

Thanks for taking a look :-)

Chris

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux