Thread: Output double
View Single Post
Old 02-16-2013, 12:03 PM   PM User | #1
mh_and
New to the CF scene

 
Join Date: Dec 2012
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
mh_and is an unknown quantity at this point
Output double

Hello,

My thanks in the beginning and please help understand what's the problem. I've started using php and trying to build my very first small website with a few categories and many pages. So I wrote a function:

Code:
function getFirstMenu() {
    $query = mysql_query("SELECT `cat_name`, `cat_id` FROM `category`") or die(mysql_error());
    while($menu = mysql_fetch_assoc($query)) {
        echo '<li><a href="?cat='.$menu['cat_id']. '">'.$menu['cat_name'].'<a/></li>';

    }
}
and I'm using it here

Code:
							<ul>
								<li><a href="index.php" target="_top">Home</a></li>
								<?php getFirstMenu();?>
							</ul>
can someone please tell me why it's outputting 2 links instead of one in a li like this. Second <a> is empty

Code:
<li>
<a href="?cat=1">Name</a>
<a></a>
</li>
Thank you
mh_and is offline   Reply With Quote