|
oim 1453
| Posté : 05-03-2007 22:49
Slt, j'ai un problème avec une fonction
function mafunction ($username){
/////Puis j'ai while avec un tableau qui utilise "$username/////
$query = mysql_query("select * from ".$NPDS where username='$username'....while (list.....
}//je ferme le while
/////Mais après j'ai besoin pour un lien de $username et là il ne s'affiche plus à cause du while je pense
echo "$username";
}
Vous auriez une idée ?
Merci ! |  Profil www
|
|
Tito 7758
| Posté : 05-03-2007 22:51
Ouais mais il ressemble à quoi ton while? |  Profil E-mail www
|
|
oim 1453
| Posté : 05-03-2007 22:54
Je voulais pas tout mettre !
function listpalindromeauteur($username) {global $ModPath, $ModStart, $NPDS_Prefix, $ThisFile; menuprincipal();
Opentable();
$rowcolor=tablos();
//Pour la naviguation
Global $start;
!include!("modules/palindrome /pal_conf.php");
if (empty($start)) { $start = 0; }
//Total pour naviguation
$result = mysql_query("select count(*) from palindrome where username='$username'");
$nbsites=0; if ($result) { $nbsites = mysql_result($result,0); }
echo "<table width=\"80%\" align=\"center\">\n";
echo "<tr align=\"center\" $rowcolor>\n";
  ; echo "<td class=\"titre\" colspan=\"5\">".palindrome_trad("Palindrome de ")."$username</td>\n";
echo "</tr>\n";
echo "<tr align=\"center\" $rowcolor>\n";
  ; echo "<td width=\"10%\">".palindrome_trad("Membre")."</td>\n";
  ; echo "<td width=\"60%\">".palindrome_trad("Phrase")."</td>\n";
  ; echo "<td width=\"10%\">".palindrome_trad("Statut")."</td>\n";
  ; echo "<td width=\"5%\">".palindrome_trad("Editer")."</td>\n";
  ; echo "<td width=\"10%\">".palindrome_trad("Supprimer")."</td>\n";
echo "</tr>\n";
  ; $query = mysql_query("select * from ".$NPDS_Prefix."palindrome where username='$username' LIMIT ". $start.",".$nb_news."");
  ; while (list($id,$phrase,$username,$en_ligne)=mysql_fetch_array($query)) {
  ;
echo "<tr $rowcolor>\n";
  ; echo "<td width=\"10%\" align=\"center\">$username</td>\n";
  ; echo "<td width=\"60%\">$phrase</td>\n";
  ; echo "<td width=\"5%\" align=\"center\">$en_ligne</td>\n";
  ; echo "<td align=\"center\" width=\"5%\"><a href=".$ThisFile."&subop=editpalindromeauteur&id=$id&username=$user name><img src=modules/palindrome/images/editer.gif border=\"0\"></a></td>\n";
echo "<td align=\"center\" width=\"10%\"><a href=".$ThisFile."&subop=suppripalauteur&id=$id&username=$username& gt;<img src=modules/palindrome/images/delete.gif border=\"0\"></a></td>\n";
echo "</tr>\n"; }
echo "</table>\n";
//Naviguation
echo "<br><table width=\"100%\" cellpadding=\"0\" cellspacing=\"3\" border=\"0\">\n";
echo "<tr>\n";
  ; echo "<td align=\"left\"><span class=\"rouge\">"; $nombre=ceil($nbsites/$nb_news);
  ; echo "".palindrome_trad("Page")." ".(($start/$nb_news)+1)." ".palindrome_trad("sur")." ".$nombre."</span> ";
  ; if($nombre>1) {
  ; for($i=1; $i<=$nombre; $i++) {
  ; $test = (($start/$nb_news)+1);
  ; if ($i==$test) {
  ; echo "[$i] "; } else {
  ; echo "[<a href=\"".$ThisFile."&subop=listpalindromeauteur&username=$username& start=".(($i-1)*$nb_news)."\">$i</a>] ";
  ; }
  ; }
  ; }
  ; echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
Closetable();
}
|  Profil www
|
|
Tito 7758
| Posté : 05-03-2007 23:31
C'est parce que dans ton list tu redéfinis la variable $username. Tu n'as qu'à utiliser un autre nom de variable et le premier $username (que tu utilises dans le mysql_query) ne sera pas altéré |  Profil E-mail www
|
|
oim 1453
| Posté : 05-03-2007 23:35
Oui mais le username du while est également pris avec celui amené par la fonction, je vois pas comment tu veux que je fasse ? |  Profil www
|
|
Tito 7758
| Posté : 06-03-2007 00:11
Mais non, tu as
$query = mysql_query("select * from ".$NPDS_Prefix."palindrome where username='$username' LIMIT ".$start.",".$nb_news);
while(list($id,$phrase,$username,$en_ligne)=mysql_fetch_array($query))
Utilise un autre nom pour le second et tout ira bien |  Profil E-mail www
|
|
oim 1453
| Posté : 06-03-2007 12:36
Merci, j'ai trouvé je fait :
  ; $query = mysql_query("select * from ".$NPDS_Prefix."contrepetrie where username='$username' LIMIT ".$start.",".$nb_news."");
  ; while ($row = mysql_fetch_row($query)) {
///et j'affiche avec $row[chiffre]
|  Profil www
|
|
Tito 7758
| Posté : 06-03-2007 18:48
Utilise mysql_fetch_assoc et tu pourras même utiliser le nom de la colonne MySQL |  Profil E-mail www
|
|