Re: link with database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sofia Jacob (CA) wrote:
> Hi,
> 
> I want to create a link that get the name and the link from the database.
> 
> The problem is that I get the bullets created with <li> but not the link, here is my code and the result:
> 
>  
> 
> <?php
> function do_html_URL($url, $name)
> {
>   // output URL as link and br
> ?>
>   <a href="<?=$url?>"><?=$name?></a><br>
> <?php
> }
> 
> ?> 
> 
> function display_categories($cat_array)
> {
>   if (!is_array($cat_array))
>   {
>      echo "No hay categorías actualmente disponibles<br>";
>      return;
>   }
>   echo "<ul>";
>   foreach ($cat_array as $row)
>   {
>       $url = "show_cat.php?Categorie_ID=".($row["Categorie_ID"]);
>        $title = $row["Catname"];
>        echo "<li>";
>        do_html_URL($url, $title);     
>   }
>   echo "</ul>";
>   echo "<hr>";
> } 
> 
> function get_categories()
> {
>    // Petición a la base de datos de una lista de categorías
>    $conn = db_connect();
>    $query = "SELECT Categorie_ID, Catname
>            FROM categories";
>    $result = @mysql_query($query);
>    if (!$result)
>      return false;
>    $num_cats = @mysql_num_rows($result);
>    if ($num_cats ==0)
>       return false;
>    $result = db_result_to_array($result); //db_fns.php
>    return $result;
> }
> 
> 
>   $cat_array = get_categories(); 
>   display_categories($cat_array);
> 
> 
> 
> 
Shorts tags are not enabled maybe?

use <?php and ?>  not <?=.

-Shawn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux