Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    343

    wall typo fb o twitter ok ---- ma non vede i post degli amici

    Ciao a tutti,
    mi sono aiutato tramite unoscript già pronto e ho creato finalmente il muro come volevo ...

    piccolo problema a differenza di quello che avevo creato io vede solo i post dell'utente loggiato e non quello di quelli che sono amici come dovrebbe ...

    Domanda ho una tabella relationship dove chi chiede amicizia e viene accettata viene messo in S altrimenti il campo enum di default e N come se venisse rifiutata....

    Lo script vecchio era questo :



    Codice PHP:
    <?php   
    include 'dbc.php';  
    page_protect();  


    ?>  
    <html>  
    <head>  
    <title>My Account</title>  
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">  

    <link href="styles.css" rel="stylesheet" type="text/css">  
    </head>  

    <body>  
    <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">  
      <tr>   
        <td colspan="3"></td>  
      </tr>  
      <tr>   
        <td width="160" valign="top">  
    <?php   
    /*********************** MYACCOUNT MENU ****************************  
    This code shows my account menu only to logged in users.   
    Copy this code till END and place it in a new html or php where  
    you want to show myaccount options. This is only visible to logged in users  
    *******************************************************************/  
    if (isset($_SESSION['user_id'])) {?>  
    <div class="myaccount">  
      

    [b]My Account[/b]</p>  
      [url="myaccount.php"]My Account[/url]
      
      [url="mysettings.php"]Settings[/url]
      
        [url="logout.php"]Logout [/url]  
          
      

    You can add more links here for users</p></div>  
    <?php }  
    if (
    checkAdmin()) {  
    /*******************************END**************************/  
    ?>  
          

     [url="admin.php"]Admin CP [/url]</p>  
          <?php ?>  
          

    </p>  
          

    </p>  
          

    </p></td>  
        <td width="732" valign="top">

    </p>  
          <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3>    
          <?php      
          
    if (isset($_GET['msg'])) {  
          echo 
    "<div class=\"error\">$_GET[msg]</div>";  
          }  
                  
          
    ?>  
          

    This is the my account page</p>  
            
          [url="accetta.php"]Controlla se hai richieste d'amicizia[/url]  
            
          
      
          
      
            
          
      
    <?php echo $_SESSION['user_name'];    
    require (
    "db_connect.php");   


    $user_id $_POST['user_id'];   



    $commento=$_POST["commento"];  
    $commento=ereg_replace("\n","
    "
    ,$commento);   

    if(
    get_magic_quotes_gpc()) {   


    $commento=stripslashes($commento);   
    }   

    $commento =mysql_real_escape_string($commento);   

    $insert mysql_query("INSERT INTO annunci SET  
    commento='
    $commento', user_id=".$_SESSION['user_id']."");   

       


    ?>  
           
     <div class="content">  
        <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">  
           
          

      
            <label for="commento"></label>  
            <textarea name="commento" id="commento" cols="55" rows="20"></textarea>  
          </p>  
          

      
            <input type="submit" name="submit" id="submit" value="Invia Commento" />  
          </p>  
        </form>  
        </div>  
          
          
       <?php   
         
         
    require ("db_connect.php");   



    $result mysql_query("SELECT * FROM  
            annunci   
           WHERE user_id="
    .$_SESSION["user_id"].
         ORDER BY `id_annunci` DESC LIMIT "
    );   


    //recuperiamo i dati da stampare   


    while ($records mysql_fetch_array($result)) {    


    $commento $records['commento'];  
    $user_name $records['user_name'];  
    $ts $records['ts'];  

    $query_ut=mysql_query("SELECT * FROM relationship WHERE id ='$id' AND amico='S'");//non so come si chiama esattamente il campo id in user  
                //verifica e correggi eventualmente  
                
    $riga_ut=mysql_fetch_array($query_ut);  
                
                

    echo 
    "<h2> [img]immagini/.gif[/img] $user_name</h2> ";   
    echo 
    "<h6>$commento</h6> ";   
    echo 
    "<h6>$ts</h6> ";   



    }   

    ?>  


        
           
           
          </td>  
        <td width="196" valign="top"></td>  
      </tr>  
      <tr>   
        <td colspan="3"></td>  
      </tr>  
    </table>  

    </body>  
    </html>

    Nello script nuovo ho un pannello functions che mi richiama tutte le funzioni...

    io ho provato così ma nada vedo solo i post di chi è loggiato e non degli amici..


    Codice PHP:
    <?php

    class Wall_Updates {

     
    // Wall friends      
          
    public function relationship ($uid
        {
           

    $query=mysql_query("SELECT * FROM relationship WHERE uid ='$uid' AND amico='S'");//non so come si chiama esattamente il campo id in user 

       
    while($row=mysql_fetch_array($query))
            
    $data[]=$row;
            return 
    $data;
            
        }   
         
    // Updates       
          
    public function Updates($uid
        {
            
    $query mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages M, users U, relationship R  WHERE M.uid_fk=U.uid and M.uid_fk='$uid' and R.uid ='$uid' AND amico='S' order by M.msg_id desc ") or die(mysql_error());
             while(
    $row=mysql_fetch_array($query))
            
    $data[]=$row;
            return 
    $data;
            
        }
        
    //Comments
           
    public function Comments($msg_id
        {
            
    $query mysql_query("SELECT C.com_id, C.uid_fk, C.comment, C.created, U.username, relationship R FROM comments C, users U , relationship R WHERE C.uid_fk=U.uid and C.msg_id_fk='$msg_id' and R.uid ='$uid' AND amico='S' order by C.com_id asc ") or die(mysql_error());
           while(
    $row=mysql_fetch_array($query))
            
    $data[]=$row;
            if(!empty(
    $data))
            {
           return 
    $data;
             }
        }
        
        
    //Avatar Image
        
    public function Gravatar($uid
        {
            
    $query mysql_query("SELECT user_email FROM `users` WHERE uid='$uid'") or die(mysql_error());
           
    $row=mysql_fetch_array($query);
           if(!empty(
    $row))
           {
            
    $user_email=$row['user_email'];
            
    $lowercase strtolower($user_email);
            
    $imagecode md5$lowercase );
            
    $data="http://www.gravatar.com/avatar.php?gravatar_id=$imagecode";
            return 
    $data;
             }
             else
             {
             
    $data="default.jpg";
            return 
    $data;
             }
        }
        
        
    //Insert Update
        
    public function Insert_Update($uid$update
        {
        
    $update=htmlentities($update);
           
    $time=time();
           
    $ip=$_SERVER['REMOTE_ADDR'];
            
    $query mysql_query("SELECT msg_id,message FROM `messages`, `relationship` WHERE uid_fk='$uid' and uid ='$uid' AND amico='S' order by msg_id desc limit 1") or die(mysql_error());
            
    $result mysql_fetch_array($query);
            
            if (
    $update!=$result['message']) {
                
    $query mysql_query("INSERT INTO `messages` (message, uid_fk, ip,created) VALUES ('$update', '$uid', '$ip','$time')") or die(mysql_error());
                
    $newquery mysql_query("SELECT M.msg_id, M.uid_fk, M.message, M.created, U.username FROM messages M, users U relationship R where M.uid_fk=U.uid and M.uid_fk='$uid' and R.uid ='$uid' AND amico='S' order by M.msg_id desc limit 1 ");
                
    $result mysql_fetch_array($newquery);
                 return 
    $result;
            } 
            else
            {
                     return 
    false;
            }
            
           
        }
        
        
    //Delete update
            
    public function Delete_Update($uid$msg_id
        {
            
    $query mysql_query("DELETE FROM `comments` WHERE msg_id_fk = '$msg_id' ") or die(mysql_error());
            
    $query mysql_query("DELETE FROM `messages` WHERE msg_id = '$msg_id' and uid_fk='$uid' and uid ='$uid' AND amico='S'") or die(mysql_error());
            return 
    true;
                     
        }
        
        
    //Insert Comments
        
    public function Insert_Comment($uid,$msg_id,$comment
        {
        
    $comment=htmlentities($comment);
                   
    $time=time();
           
    $ip=$_SERVER['REMOTE_ADDR'];
            
    $query mysql_query("SELECT com_id,comment FROM `comments`, `relationship`  WHERE uid_fk='$uid' and msg_id_fk='$msg_id' and uid ='$uid' AND amico='S' order by com_id desc limit 1 ") or die(mysql_error());
            
    $result mysql_fetch_array($query);
        
            if (
    $comment!=$result['comment']) {
                
    $query mysql_query("INSERT INTO `comments`, `relationship` (comment, uid_fk,msg_id_fk,ip,created) VALUES ('$comment', '$uid','$msg_id', '$ip','$time')") or die(mysql_error());
                
    $newquery mysql_query("SELECT C.com_id, C.uid_fk, C.comment, C.msg_id_fk, C.created, U.username FROM comments C, users U, relationship where C.uid_fk=U.uid and C.uid_fk='$uid' and C.msg_id_fk='$msg_id' and R.uid ='$uid' AND amico='S' order by C.com_id desc limit 1 ");
                
    $result mysql_fetch_array($newquery);
             
               return 
    $result;
            } 
            else
            {
            return 
    false;
            }
           
        }
        
        
    //Delete Comments
            
    public function Delete_Comment($uid$com_id
        {
            
    $query mysql_query("DELETE FROM `comments` WHERE uid_fk='$uid' and com_id='$com_id' and uid ='$uid' AND amico='S'") or die(mysql_error());
            return 
    true;
                     
        }

        

    }

    ?>
    Tabella relationship.. ( se può' aiutarmi a sciogliere questo arcano )

    Codice PHP:
    -- phpMyAdmin SQL Dump 
    -- version 3.3.7 
    -- [url]http://www.phpmyadmin.net[/url] 
    -- 
    -- 
    Hostlocalhost 
    -- Generato il09 nov2011 at 10:18 PM 
    -- Versione MySQL5.1.44 
    -- Versione PHP5.3.2 

    SET SQL_MODE
    ="NO_AUTO_VALUE_ON_ZERO"


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */
    /*!40101 SET NAMES utf8 */

    -- 
    -- 
    Database: `yes-friends
    -- 

    -- -------------------------------------------------------- 

    -- 
    -- 
    Struttura della tabella `relationship
    -- 

    CREATE TABLE IF NOT EXISTS `relationship` ( 
      `
    idint(10NOT NULL AUTO_INCREMENT
      `
    user_1varchar(10NOT NULL
      `
    user_2varchar(10NOT NULL
      `
    amicoenum('S','N'NOT NULL DEFAULT 'N'
      
    PRIMARY KEY (`id`) 
    ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=37 

    -- 
    -- 
    Dump dei dati per la tabella `relationship
    -- 

    INSERT INTO `relationship` (`id`, `user_1`, `user_2`, `amico`) VALUES 
    (12'54''57''S'), 
    (
    9'54''57''S'), 
    (
    8'54''55''S'), 
    (
    7'54''58''N'), 
    (
    11'55''54''S'), 
    (
    13'57''54''S'), 
    (
    14'57''57''N'), 
    (
    15'57''55''S'), 
    (
    16'54''60''N'), 
    (
    17'57''54''S'), 
    (
    18'57''58''N'), 
    (
    19'57''59''N'), 
    (
    20'57''60''N'), 
    (
    21'54''61''S'), 
    (
    22'57''61''N'), 
    (
    24'54''62''N'), 
    (
    25'54''55''S'), 
    (
    26'54''55''S'), 
    (
    27'54''55''S'), 
    (
    28'55''58''N'), 
    (
    29'55''54''S'), 
    (
    30'57''58''N'), 
    (
    31'63''61''S'), 
    (
    32'63''61''S'), 
    (
    33'63''61''S'), 
    (
    34'63''61''S'), 
    (
    35'54''58''N'); 

  2. #2
    Utente di HTML.it
    Registrato dal
    Apr 2010
    Messaggi
    343
    Ragazzi ma nessuno riesce a capire come si può fare a risolvere questo problema ?????

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 © 2024 vBulletin Solutions, Inc. All rights reserved.