Display the each category name in the table as a link

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vishalgupta
    New Member
    • Jun 2007
    • 47

    Display the each category name in the table as a link

    in the following code i am trying to display the each category name in the table as a link to cat.html [code=php]
    <html>
    <head>
    </head>
    <body>
    <?php
    $str1="<a href=cat.html>" ;
    $str2="<//a>";
    $user_name="roo t";
    $password="";
    $database="myfo rum";
    $server="localh ost";
    $db_handle=mysq l_connect($serv er,$user_name,$ password);
    $db_found=mysql _select_db($dat abase,$db_handl e);
    if($db_found)
    {
    echo "Forum database found"."<BR>";
    $SQL="select * from categories";
    $result=mysql_q uery($SQL);
    while($db_field =mysql_fetch_as soc($result))
    {
    print $db_field['id']."<BR>";
    $str1.$db_field['name'].$str2;
    //print $db_field['name']."<BR>";
    print $db_field['topics']."<BR>";
    }
    }
    else
    {
    echo "Forum database not found";
    }
    mysql_close($db _handle);
    ?>
    </body>[/code]however it only shows :
    Forum database found
    1
    0

    (only one row in database)

    can someone please help me as to why isnt it showing the category name as a link ?
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    can someone please help me as to why isnt it showing the category name as a link
    Because you are not printing it out
    [PHP]$str1.$db_field['name'].$str2;[/PHP] is an empty statement without print.

    Comment

    Working...