Is there a better way to write this?
| From: | Chris Payne | Date: | Mon, 18 Aug 2003 04:16:11 +0000 |
| Subject: | Is there a better way to write this? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-29932@lists.php.net to get a copy of this message | ||
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