<?php
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" xml:lang="fr" />
<title>Créer un tableau dans une boucle</title>
<style type="text/css">
/* <![CDATA[ */
table, th, td {border: 1px solid #999;}
/* ]]> */
</style>
</head>
<body>
<?php
$tableau = array("id" => array(1, 2, 3), "nom" => array("Dudule", "Toto", "Machin"));
/* Création d'un tableau : la première partie sera l'en-tête et n'a pas besoin d'être répétée */
?>
<table summary="">
<tr>
<th>Identifiant</th>
<th>Pseudonyme</th>
</tr>
<?php
/* Maintenant on va créer une nouvelle ligne dans notre tableau par ligne de données : on utilise une boucle */
if(false !== $tableau)
{
/* On récupère le nombre de ligne de données */
$nb = count($tableau['id']);
/* On va maintenant boucler et à chaque tour créer une ligne */
for($i = 0; $i < $nb; $i++)
{
?>
<tr>
<td><?php echo($tableau['id'][$i]); ?></td>
<td><?php echo($tableau['nom'][$i]); ?></td>
</tr>
<?php
}
}
?>
</table>
</body>
</html>
Lis bien ce code, note tes questions, réfléchis avant de les poser, tu trouveras toi-même beaucoup de réponses et viens poser les autres ici.<?php
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" xml:lang="fr" />
<title>Créer un tableau dans une boucle</title>
<style type="text/css">
/* <![CDATA[ */
table, th, td {border: 1px solid #999;}
/* ]]> */
</style>
</head>
<body>
<?php
$_SESSION['login'] = $_POST['pseudo'];
require("connect.php");
if(isset($_POST['pseudo'])) {
$verif= mysql_query("SELECT * FROM `mix` WHERE artiste LIKE '".$_SESSION['login']."' ");
$row=mysql_fetch_array($verif);
$arr = array("Nom" => array($row['nom']), "Description" => array($row['description']));
$tableau = array("id" => array($row['nom']), "nom" => array($row['description']));
/* Création d'un tableau : la première partie sera l'en-tête et n'a pas besoin d'être répétée */
?>
<table summary="">
<tr>
<th>Nom</th>
<th>Lien</th>
</tr>
<?php
/* Maintenant on va créer une nouvelle ligne dans notre tableau par ligne de données : on utilise une boucle */
if(false !== $tableau)
{
/* On récupère le nombre de ligne de données */
$nb = count($tableau['id']);
/* On va maintenant boucler et à chaque tour créer une ligne */
for($i = 0; $i < $nb; $i++)
{
?>
<tr>
<td><?php echo($tableau['id'][$i]); ?></td>
<td><?php echo($tableau['nom'][$i]); ?></td>
</tr>
<?php
}
}
}
?>
</table>
</body>
</html><?php
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" xml:lang="fr" />
<title>Créer un tableau dans une boucle</title>
<style type="text/css">
/* <![CDATA[ */
table, th, td {border: 1px solid #999;}
/* ]]> */
</style>
</head>
<body>
<?php
$_SESSION['login'] = $_POST['pseudo'];
require("connect.php");
if(isset($_POST['pseudo'])) {
$verif= mysql_query("SELECT * FROM `mix` WHERE artiste LIKE '".$_SESSION['login']."' ");
/* Création d'un tableau : la première partie sera l'en-tête et n'a pas besoin d'être répétée */
?>
<table summary="">
<tr>
<th>Nom</th>
<th>Lien</th>
</tr>
<?php
/* Maintenant on va créer une nouvelle ligne dans notre tableau par ligne de données : on utilise une boucle */
$verif= mysql_query("SELECT * FROM `mix` WHERE artiste LIKE '".$_SESSION['login']."' ");
while($row=mysql_fetch_array($verif))
{
echo "
<tr>
<td>".$row['id']."</td>
<td>".$row['nom']."</td>
</tr>";
}
}
?>
</table>
</body>
</html>$verif = mysql_query("SELECT `nom`, `description` FROM `mix` WHERE artiste LIKE '%". $_SESSION['login'] ."%' ");
ou bien:
$verif = mysql_query("SELECT `nom`, `description` FROM `mix` WHERE artiste = '". $_SESSION['login'] ."' ");
Le résultat risque de ne pas être le même selon le cas.if(isset($_POST['pseudo']))
{
$arr = array("Nom" => array(), "Description" => array());
$tableau = array("id" => array(), "nom" => array());
$verif = mysql_query("SELECT `nom`, `description` FROM `mix` WHERE artiste LIKE '%". $_SESSION['login'] ."%' ");
while(($row = mysql_fetch_array($verif)) != false)
{
$arr['Nom'][] = $row['nom'];
$arr['Description'][] = $row['description'];
$tableau['id'][] = $row['nom'];
$tableau['nom'][] = $row['description'];
}
/* Création d'un tableau : la première partie sera l'en-tête et n'a pas besoin d'être répétée */
?>
Est-ce que tu visualises à peu près correctement le déroulement ? C'est important, sinon, j'explique pour rien, j'aime mieux que tu arrêtes pour assimiler et demander des compléments d'information plutôt que de faire une impasse... Mais réfléchis bien et pose toi les question : "Ceci sert à quoi ? à faire telle chose, ok, ensuite, etc..."<?php
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" xml:lang="fr" />
<title>Créer un tableau dans une boucle</title>
<style type="text/css">
/* <![CDATA[ */
table, th, td {border: 1px solid #999;}
/* ]]> */
</style>
</head>
<body>
<?php
$_SESSION['login'] = $_POST['pseudo'];
require("connect.php");
if(isset($_POST['pseudo']))
{
$verif = mysql_query("SELECT `nom`, `description` FROM `mix` WHERE artiste LIKE '%". $_SESSION['login'] ."%' ");
/* Création d'un tableau : la première partie sera l'en-tête et n'a pas besoin d'être répétée */
?>
<table summary="">
<tr>
<th>Nom</th>
<th>Lien</th>
</tr>
<?php
/* Maintenant on va créer une nouvelle ligne dans notre tableau par ligne de données : on utilise une boucle */
while(($row = mysql_fetch_array($verif)) != false)
{
/* On va maintenant boucler et à chaque tour créer une ligne */
?>
<tr>
<td><?php echo($row['nom']); ?></td>
<td><?php echo($row['Description']); ?></td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</body>
</html>
Le sabre bien tranchant, c'est toujours pratique $verif = mysql_query("SELECT `nom`, `description` FROM `mix` WHERE artiste LIKE '%". $_SESSION['login'] ."%' ");
Tu ne sélectionnes que `nom` et `description`, ajoutes-y les champs voulus.