PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > link with database
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
link with database

Réponse
 
LinkBack Outils de la discussion
Vieux 11/03/2008, 21h06   #1
Shawn McKenzie
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: link with database

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
  Réponse avec citation
Vieux 11/03/2008, 21h11   #2
Shawn McKenzie
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: link with database

Shawn McKenzie wrote:
> 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

Also, you need to close your <li> with </li> after. That should be
fixed, but you can confirm by looking at your page source. If you see:

<li><a href=""></a><br>

Then short tags are not enabled.

-Shawn
  Réponse avec citation
Vieux 11/03/2008, 21h31   #3
Sofia Jacob \
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut link with database

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);




  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h48.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 2,84873 seconds with 11 queries