27. august 2006 - 12:52Der er
15 kommentarer og 1 løsning
Hjælp til mysql_query
Hej
Nogen der kan hjælpe mig med denne query?
$query = mysql_query("SELECT *, users.name AS name, DATE_FORMAT(topic.date,'%d/%m/%Y - %H:%i') as date FROM topic, users WHERE topic.forum_id = '".$id."' AND users.id = topic.user_id ORDER BY topic.id DESC LIMIT $show_from, $page_limit") or die(mysql_error()); while ($row = mysql_fetch_array($query)) { echo $row['id'].'<br />'; }
Den udskriver 3 id's som den skal, men ved allesammen skriver den 1.
$query = mysql_query("SELECT *, users.name AS name, DATE_FORMAT(topic.date,'%d/%m/%Y - %H:%i') as date FROM topic, users WHERE topic.forum_id = '"$id"' AND users.id = topic.user_id ORDER BY topic.id DESC LIMIT $show_from, $page_limit") or die(mysql_error()); while ($row = mysql_fetch_array($query)) { echo $row['id'].'<br />'; }
$sql = "SELECT topic.id AS topicid*, users.name AS name, DATE_FORMAT(topic.date,'%d/%m/%Y - %H:%i') AS date FROM topic, users WHERE topic.forum_id = '" . $id . "' AND users.id = topic.user_id ORDER BY topic.id DESC LIMIT $show_from,$page_limit";
$query = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($query)) { echo $row['topicid'] . '<br />'; }
$sql = "SELECT topic.id AS topicid, *, users.name AS name, DATE_FORMAT(topic.date,'%d/%m/%Y - %H:%i') AS date FROM topic, users WHERE topic.forum_id = '" . $id . "' AND users.id = topic.user_id ORDER BY topic.id DESC LIMIT $show_from,$page_limit";
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*, users.name AS name, DATE_FORMAT(topic.date,'%d/%m/%Y - %H:' at line 1
$sql = "SELECT *, topic.id AS topicid, users.name AS name, DATE_FORMAT(topic.date,'%d/%m/%Y - %H:%i') AS date FROM topic, users WHERE topic.forum_id = '" . $id . "' AND users.id = topic.user_id ORDER BY topic.id DESC LIMIT $show_from,$page_limit";
Takker for point og takker for karma (Omend jeg er mere glad for dem når der også medfølger en slags begrundelse. Jeg er dog ligeglad med om de er anonyme eller ej. :^)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.