Jump to content

Best way to query this. >_>


DarkWater

Recommended Posts

I rewrote a script I made to display posted comments, because I realized I was using a lot of unnecessary MySQL return values.  I rewrote it to simply be this:

<?php
$query="SELECT u.username, comments.* FROM comments, users as u WHERE comments.user_id = u.user_id ORDER BY comment_id DESC";
$result=mysql_query($query) or die (mysql_error());

while ($row=mysql_fetch_array($result, MYSQL_ASSOC)) {

echo stripslashes($row['comments']) . "<br /> posted by " . $row['username'] . "  <a href=\"./comments.php?id={$row['comment_id']}\">delete</a><hr width=30% align=\"left\"><br />";
}
?>

 

Is there any way to make that query any better?

 

EDIT: I hardly make new topics asking for help, but I just want to know if there's a simpler query. =P  I doubt it though/

Link to comment
https://forums.phpfreaks.com/topic/102755-best-way-to-query-this-_/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.