weird output

admin

Administrator
Staff member
Hello, all

Below code was supposed to get the result of

cat1 | cat2
cat3 | cat4

---------code start here ---------------
<?
include ("config.php");
//config.php contains all database connection info.
?>
<table><tr>
<?
$i=1;
$query="select cat from category";
$exec=mysql_query($query,$db);
while ($row=mysql_fetch_array($exec)) {
$result=$row["cat"];
echo "<td>";
echo "<a href=http://www.phpbuilder.com/board/archive/index.php/\"display_all.php?category=$result\">$result</a>";
echo " |";
echo "</td>";

if ($i=2) {
echo "</tr><tr>";
$i=1;
}
$i++;
}
echo "</table>"
?>
----------code end here-------------------

But after run the script, I get below result:
cat1 |
cat2 |
cat3 |
cat4 |

<table><tr>
<td><a href="display_all.php?category=cat1">cat1</a> |</td></tr><tr><td><a href="display_all.php?category=cat2">cat2</a> |</td></tr><tr><td><a href="display_all.php?category=cat3">cat3</a> |</td></tr><tr><td><a href="display_all.php?category=cat4">cat4</a> |</td></tr><tr></table>

I would be appreciated if anybody could tell me what the problem is. Thank you all for your time.
 
Back
Top