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 :
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..
Tabella relationship..
Spero che qualcuno mi aiuti a risolvere il problema ...
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"> </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> </p>
<p> </p>
<p> </p></td>
<td width="732" valign="top"><p> </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"> </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..
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 @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` (
`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 ...