logo

NPDS : Gestion de contenu et de communauté


Content & Community Management System (CCMS) robuste, sécurisé, complet, performant, parlant vraiment français, libre (Open-Source) et gratuit.
25 visiteur(s) et 0 membre(s) en ligne.
Activité du Site

Pages vues depuis 25/05/2001 : 109 491 255

  • Nb. de membres 8 696
  • Nb. d'articles 1 695
  • Nb. de forums 26
  • Nb. de sujets 8
  • Nb. de critiques 92

Top 10  Statistiques

Index du forum »»  Le coin des codeurs »» [Résolu] - function+while

[Résolu] - function+while#22040

2Contributeur(s)
oimTito
3 Modérateur(s)
developpeurjpbJireck
oim oimicon_post
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 !
Tito Titoicon_post
Ouais mais il ressemble à quoi ton while? :-?
oim oimicon_post
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=$username><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><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();
}

Tito Titoicon_post
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é
oim oimicon_post
Oui mais le username du while est également pris avec celui amené par la fonction, je vois pas comment tu veux que je fasse ?
Tito Titoicon_post
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
oim oimicon_post
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]


:-)
Tito Titoicon_post
Utilise mysql_fetch_assoc et tu pourras même utiliser le nom de la colonne MySQL :=!