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

searedone

Utente Attivo
11 Giu 2010
508
0
0
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 :

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">&nbsp;</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"> 
  <p><strong>My Account</strong></p> 
  <a href="myaccount.php">My Account</a><br> 
  <a href="mysettings.php">Settings</a><br> 
    <a href="logout.php">Logout </a> 
     
  <p>You can add more links here for users</p></div> 
<?php } 
if (checkAdmin()) { 
/*******************************END**************************/ 
?> 
      <p> <a href="admin.php">Admin CP </a></p> 
      <?php } ?> 
      <p>&nbsp;</p> 
      <p>&nbsp;</p> 
      <p>&nbsp;</p></td> 
    <td width="732" valign="top"><p>&nbsp;</p> 
      <h3 class="titlehdr">Welcome <?php echo $_SESSION['user_name'];?></h3>   
      <?php     
      if (isset($_GET['msg'])) { 
      echo "<div class=\"error\">$_GET[msg]</div>"; 
      } 
             
      ?> 
      <p>This is the my account page</p> 
       
      <a href="accetta.php" />Controlla se hai richieste d'amicizia</a> 
       
      <br /> 
      <br /> 
       
      <br /> 
<?php echo $_SESSION['user_name'];   
require ("db_connect.php");  


$user_id = $_POST['user_id'];  



$commento=$_POST["commento"]; 
$commento=ereg_replace("\n","<br>",$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']; ?>"> 
      
      <p> 
        <label for="commento"></label> 
        <textarea name="commento" id="commento" cols="55" rows="20"></textarea> 
      </p> 
      <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 src='immagini/.gif' width='30' height='50' /> $user_name</h2> ";  
echo "<h6>$commento</h6> ";  
echo "<h6>$ts</h6> ";  



}  

?> 


   
      
      
      </td> 
    <td width="196" valign="top">&nbsp;</td> 
  </tr> 
  <tr>  
    <td colspan="3">&nbsp;</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..

PHP:
<?php
//Srinivas Tamada http://9lessons.info
//Wall_Updates

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  WHERE M.uid_fk=U.uid and M.uid_fk='$uid' 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 FROM comments C, users U WHERE C.uid_fk=U.uid and C.msg_id_fk='$msg_id' and 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` 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 where M.uid_fk=U.uid and M.uid_fk='$uid' and 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` 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` (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 where C.uid_fk=U.uid and C.uid_fk='$uid' and C.msg_id_fk='$msg_id' and 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..
PHP:
-- phpMyAdmin SQL Dump
-- version 3.3.7
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 09 nov, 2011 at 10:18 PM
-- Versione MySQL: 5.1.44
-- Versione PHP: 5.3.2

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;
/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;
/*!40101 SET @[email protected]@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

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

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

--
-- Struttura della tabella `relationship`
--

CREATE TABLE IF NOT EXISTS `relationship` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `user_1` varchar(10) NOT NULL,
  `user_2` varchar(10) NOT NULL,
  `amico` enum('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');

Spero che qualcuno mi aiuti a risolvere il problema ...
 

searedone

Utente Attivo
11 Giu 2010
508
0
0
gentilmente nessuno riesce ad aiutarmi ??? ci sbatto la testa da ieri ma non capisco che devo fare :(

ho provato anche così ad inserire relationship ma nulla sempre e solo i post dell'utente loggiato come se fosse la sua bacheca :(

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;
      	       
    }

    

}

?>
 
Discussioni simili
Autore Titolo Forum Risposte Data
P wall in asp Classic ASP 1
A www.wallproject.it tributo a The Wall dei Pink Floyd Presenta il tuo Sito 0
S All Wall Street Presenta il tuo Sito 2
A Twitter aggiungere tweet a campagna esistente o salvare pubblico Social Media Marketing 0
P Vendo incrementi fan pagine facebook/instagramm/twitter Annunci servizi di Social Media Marketing 5
megmalamadre [VENDO] Facebook fan/ Instagram-Twitter follower / Youtube views / ecc ecc... Annunci servizi di Social Media Marketing 7
Nagath [VENDO] FB Likes/Followers Instagram/Twitter/Views Youtube Annunci servizi di Social Media Marketing 5
orl4c [VENDO] Pagina 220k reali, sito, youtube,twitter inclusi Annunci servizi di Social Media Marketing 0
giuspeppesocial [VENDO] Sito web completo [scontsita.com] + Pagina FB + Twitter Compravendita siti e domini 0
J Gestisco e creo Pagine fecebook, instagram, twitter, youtube, massima serietà, crescita garantita! Annunci servizi di Social Media Marketing 0
V Api di twitter cambiata Ajax 0
romeocharly software per visite sito , youtube , facebook, twitter ... SEO e Posizionamento 0
lucolo [VENDO] Followers per Twitter Annunci servizi di Social Media Marketing 0
ecosito Limite di 1 tweet sul Plugin di Twitter Javascript 2
F Problema con il Facebook Plug-in e i Badge Google + e Twitter HTML e CSS 1
Nagath [VENDO] Servizi likes/followers Instagram/Twitter/Views Youtube Annunci servizi di Social Media Marketing 4
N [Vendo] Facebook Like e Follower su Twitter Annunci servizi di Social Media Marketing 1
izen [Vendo] Incremente Facebook, YouTube, Instagram, Twitter, G+1 e molto altro! Annunci servizi di Social Media Marketing 0
N [Vendo] Facebook Like e Follower su Twitter Annunci servizi di Social Media Marketing 0
braccobaldo Aumento follower su Twitter = miglioramento del posizionamento? SEO e Posizionamento 7
lucolo [VENDO] Followers per Facebook, Instagram e Twitter Annunci servizi di Social Media Marketing 4
V [Vendo]Like,Follower su Facebook e Instagram, Retweet e Favoriti su Twitter e tanto altro! Annunci servizi di Social Media Marketing 0
Violetta De Amicis facebook, twitter e Windows 7 Windows e Software 3
lucolo [VENDO] Condivisioni su Facebook, LinkedIn e Twitter Annunci servizi di Social Media Marketing 1
lucolo [VENDO] Pinterest, VK, Twitter, Facebook ed Instagram followers Annunci servizi di Social Media Marketing 2
J VENDO facebook like fans Twitter Youtube Instagram Vine Annunci servizi di Social Media Marketing 2
M Fanpage Facebook Followers Twitter, Seguaci Instagram a prezzi stracciati. Annunci servizi di Social Media Marketing 1
G [VENDO] FAN Facebook, Followers Twitter, Visite siti, Visite&commenti youtube Annunci servizi di Social Media Marketing 1
Marcolotto Twitter ADV è presente in Italia? Social Media Marketing 2
N Vendo likes fb/yt/twitter/ ecc... Annunci servizi di Social Media Marketing 0
S [vendo] Facebook likes/twitter followers/visualizzazioni youtube Annunci servizi di Social Media Marketing 0
N [vendo] 12€ vendo italiani mi piace, yt views, twitter ecc... Annunci servizi di Social Media Marketing 0
J [VENDO]Like FaceBook - Iscrizioni/Visualizzazioni Youtube/Twitter/SitoWeb Annunci servizi di Social Media Marketing 23
T Condivisione su Facebook e Twitter all'interno di app Android Sviluppo app per Android 1
J Twitter API nuova ver 1.1 PHP 0
N [VENDO] -Facebook: "mi piace" ,condivisioni....anche Youtube, twitter,instagram... Annunci servizi di Social Media Marketing 1
F [Vendo] Fans e Followers Facebook e Twitter Annunci servizi di Social Media Marketing 0
D Una piccola curiosità su facebook e twitter Javascript 2
promuovimi [Vendo] Fans Facebook, YouTube, Twitter..italiani a miglior prezzo. Annunci servizi di Social Media Marketing 0
Nagath [Vendo] Facebook "Mi piace" , Follower Instagram e Twitter,Visualizzazioni Youtube Annunci servizi di Social Media Marketing 10
A Vendo visualizzazioni, iscrizioni, mi piace(youtube,facebook,instagram,twitter) Annunci servizi di Social Media Marketing 0
A [VENDO]Facebook fans, twitter followers,traffico italiano, traffico alexa,backlinks, commenti blog Annunci servizi di Social Media Marketing 3
J Vendo fans mi piace per fanpage facebook e follower twitter - massima serieta' Annunci servizi di Social Media Marketing 0
F integrare/collegare twitter al proprio sito PHP 1
Mauro Guardiani sign in with twitter Discussioni Varie 1
M [compro] Spam di link su facebook, twitter, blog, siti, mail etc Annunci servizi di Social Media Marketing 0
J Vendo mi piace facebook, follower twitter visite sito e visite youtube Annunci servizi di Social Media Marketing 1
D API Twitter Discussioni Varie 2
H [VENDO] twitter followers Annunci servizi di Social Media Marketing 2
X [VENDO] Faceboook Fans, Visite Youtube, Twitter Followers, Google +1 Annunci servizi di Social Media Marketing 2

Discussioni simili