Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Query al db con where estratto.

    Salve gente spero possiate aiutarmi, sto realizzando un applicazione abbastanza complessa a dire il vero, trattasi di qualcosa stile twitter con possibilità di seguire gli utenti e vedersi pubblicati i loro post in bacheca, ho realizzato la gestionde delle richieste per seguire gli utenti, i profili etc, fin qui tutto ok, anche le pubblicazioni in bacheca inrealtà sono ok, tranne per un particolare posto il codice:
    Codice PHP:
    function __comment()
    {
    $id $_SESSION['id'];
    $friends mysql_query ("select myfriends from friends where idmy = '$id'");

    //$data = mysql_query ("select data  from post where iduser = '$readidinarray' ");
    while ($readid mysql_fetch_array ($friends)){

        
    $readidinarray = array  ($readid['myfriends']);
         foreach (
    $readidinarray as $readidinarray)
       {
           
    $data mysql_query ("select data  from post where iduser = '$readidinarray'  ");
            
    $readidinarray.'
    '
    ;
           while (
    $dataread mysql_fetch_array ($data))
           {
               echo 
    $dataread['data'].'
    '
    ;
               
    $query mysql_query("select * from post where data = '".$dataread['data']."' order by data desc ");    
               while (
    $readcomment mysql_fetch_array ($query))
               {
                   
                   
    __readcomment($readcomment);
                   
                   }
               
               } 
         
        }
    }
        
     

    nella query $friends estraggo gli id delle persone che seguo , le ciclo e creo un array associativo per estrarre i post che vengono stampati tramite una funzione esterna che richiamo, cioè questa
    Codice PHP:
       __readcomment($readcomment); 
    ma non riesco a stamapre i post ordinati per data/utente, nel senso che lo script stampa i risultati per data ma, per ogni utente alla volta:
    Spiego meglio se io sono "tizio" e scrivo "ciao mondo" e l'utente "caio" scrive "salve gente" e "che si fa di bello" etc i post vengono stampati in blocchi sequenziali in base all'utente, anche se per data, insomma posto un immagine



    in alternativa uso questa classe
    Codice PHP:
     class showallpost

    {
        
    public 
    $friendsnum;
    public 
    $query;
    public 
    $query_friendsid_pure;
    public 
    $myid;
    public 
    $queryextract;
    public 
    $timefor_post;
    public 
    $data;

    function 
    __construct()

    {    
    $this->myid $_SESSION['id'];    
        
    $this->query mysql_query ("select myfriends from friends 
          where idmy = '
    $this->myid' order by data desc");
         
    $this->query_friendsid_pure mysql_query("select myfriends from friends inner join post on iduser = 
        '
    $this->friendsnum' where myfriends = '$this->friendsnum' order by data desc");
        
        
        
    }    
        
    public function 
    __cicle_query_friends_pure($unm_for_friendsid,$cilce)

      
       
        while (
    $unm_for_friendsid mysql_fetch_array ($this->query))
        {
             
             
    $this->friendsnum $unm_for_friendsid['myfriends'].'
    '
    ;
              
    $this->timefor_post mysql_query ("select data from post where iduser = '$this->friendsnum'");
             while (
    $read_data mysql_fetch_array ($this->timefor_post))
             {
                 
                 echo 
    $this->data $read_data['data'];
                 
                 
              
    $this->queryextract mysql_query("select * from  
             post  order by data desc "
    );
         
         
    // if ($this->queryextract == true){echo "true";}else{echo "ni";}
        
    while ($readcomment mysql_fetch_array($this->queryextract))
        {
             
              if (
    $readcomment['fotoid'] == null)
              {
                 if (
    $readcomment['fotopost'] ==  null)
                 {
                     
                        echo (
    "<div id='commentihome'>");
                          echo 
    "<div id='headoncomment'>";
                         echo 
    "[img]images/Clip/defaultmedium.gif[/img]".'</a>'.'</p>'.
                     
                          
    '[url="profile.php?user='.$readcomment['iduser'].'"]'stripslashes $readcomment ['nome'] . $readcomment ['cognome']) . "[/url]";
                          echo 
    date("F j, Y, g:i a"$readcomment['data'])."<p class='chiudi'>X</p>";
                          echo 
    "</div>";
                         echo  
    "

    "
    .stripslashes ($readcomment['commento'].'
    '
    )."</p>";
                       
                        echo 
    "<div id='footcomment'>";
                        echo 
    "</div>";
                             
                       
                       echo 
    $this->overlay;
                       echo 
    "</div>";
                                 
                }else if (
    $readcomment ['fotopost'] == true)
                {
                         
    $fotopost $readcomment['fotopost'];
                         echo (
    "<div id='commentihome'>");
                          
                             echo 
    "<div id='headoncomment'>";
                          echo 
    "[img]images/Clip/defaultmedium.gif[/img]".'</a>'.'</p>'.
                          
    '[url="profile.php?user='.$readcomment['iduser'].'"]'stripslashes $readcomment ['nome'] . $readcomment ['cognome']) . "[/url]";
                           echo 
    date("F j, Y, g:i a"$readcomment['data'])."<p class='chiudi'>X</p>";
                        
                          echo 
    "</div>";
                         echo  
    "

    "
    .stripslashes ($readcomment['commento'].'
    '
    )."</p>";
                       
                         echo 
    "<img src=/images/fotopost/$fotopost style='width:350px' height='350px'>".'
    '
    ;
                       echo 
    "<div id='footcomment'>";
                        echo 
    "</div>";
                             
                         echo 
    "</div>";
                        
                    
                    
                }  
                  
                  
                  
                  
                  
              }
              if (
    $readcomment['fotoid'] == true)
              {
                  
    $myfoto $readcomment['fotoid'];
                  
                  if (
    $readcomment['fotopost'] ==  null)
                 {
                     
                        echo (
    "<div id='commentihome'>");
                            echo 
    "<div id='headoncomment'>";
                          echo 
    "<img src=/images/avatar/$myfoto style='width:40px' height='40px'>".
                       
                       
                         
    '[url="profile.php?user='.$readcomment['iduser'].'"]'stripslashes $readcomment ['nome'] . $readcomment ['cognome']) . "[/url]";
                           echo 
    date("F j, Y, g:i a"$readcomment['data'])."<p class='chiudi'>X</p>";
                          echo 
    "</div>";
                         echo  
    "

    "
    .stripslashes ($readcomment['commento'].'
    '
    )."</p>";
                       
                         
                        echo 
    "<div id='footcomment'>";
                        echo 
    "</div>";
                             
                         
                       
                       echo 
    "</div>";
                                 
                }else if (
    $readcomment['fotopost'] == true)
                {
                    
                       
    $fotopost $readcomment['fotopost'];
                         echo (
    "<div id='commentihome'>");
                             echo 
    "<div id='headoncomment'>";
                          echo 
    "<img src=/images/avatar/$myfoto style='width:40px' height='40px'>".
                         
                          
    '[url="profile.php?user='.$readcomment['iduser'].'"]'stripslashes $readcomment ['nome'] . $readcomment ['cognome']) .'[/url]';
                         
                          echo 
    date("F j, Y, g:i a"$readcomment['data'])."<p class='chiudi'>X</p>";
                         
                          echo 
    "</div>";
                         echo  
    "

    "
    .stripslashes ($readcomment['commento'].'
    '
    )."</p>";
                       
                         echo 
    "<img src=/images/fotopost/$fotopost style='width:350px' height='350px'>".'
    '
    ;
                       echo 
    "<div id='footcomment'>";
                        echo 
    "</div>";
                             
                         echo 
    "</div>";
                    
                }
                  
                  
             }
              
              
            
            
            
            }
        
        
        }
    }  
         
    }


            

    01001101 01000001 01010010 01001001 01001111 01000000 01001101 01001111 01001110 01000101☺☻

  2. #2
    Up----
    Nessuno ci ha capito niente...lo sapevo
    01001101 01000001 01010010 01001001 01001111 01000000 01001101 01001111 01001110 01000101☺☻

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.