Последни теми ...

Fakeheal

Super Moderator
Имам този код:
<?php
$connection = mysql_connect(localhost,"root","") or die("Service temporairly unavailable");
$db = mysql_select_db("sait",$connection) or die("Service temporairly unavailable");
$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10";
$result = mysql_query($sql) or die("Service temporairly unavailable");
for($x=1;$x<=10;$x++){
$row = mysql_fetch_array($result);
echo "»<a href = \"http://forum.monsterkill.info/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a>";
}
?>

и трябва да изкарва последните теми от PHPBB3 форум, но защо ми излиза така

1613457s.png


Искам само отпред да е този знак >>
 
пробвай така



<?php
$connection = mysql_connect(localhost,"root","") or die("Service temporairly unavailable");
$db = mysql_select_db("sait",$connection) or die("Service temporairly unavailable");
$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10";
$result = mysql_query($sql) or die("Service temporairly unavailable");
for($x=1;$x<=10;$x++){
while($row = mysql_fetch_array($result)){
echo "»<a href = \"http://forum.monsterkill.info/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a>";
}}
?>
 
<?php
$connection = mysql_connect(localhost,"root","") or die("Service temporairly unavailable");
$db = mysql_select_db("sait",$connection) or die("Service temporairly unavailable");
$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,10";
$result = mysql_query($sql) or die("Service temporairly unavailable");
for($x=1;$x<=10;$x++){
while($row = mysql_fetch_array($result))
{
echo "»<a href = \"http://forum.monsterkill.info/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a>";
}
}
?>

и да обясня.

когато използваш mysql_fetch_array без while ти взимаш само един резултат от бд-то.

а когато използваш цикъла while изкарваш всички записи.
 

Back
Горе