bacheca interazione tra utenti stile facebook ...

var dump mysql_query

Codice:
string(247) "SELECT * FROM annunci AS p WHERE p.id_utente = '54' OR p.id_utente IN (SELECT user_1 FROM relationships AS r WHERE r.user_2 = '54' AND r.amico = 'S') OR p.id_utente IN (SELECT user_2 FROM relationships AS r WHERE r.user_1 = '54' AND r.amico = 'S')"

Passa solo l'id dell'utente loggatoooo
 
Allora nella bacheca devono esserci i messaggi dell' user_id ma tutti quelli che gli hanno chiesto amicizia devono poter vedere i suoi post e viceversa lui deve vedere quelli dei suoi amici.....
 
se invece aggiungo user_id a: WHERE p.user_id =

mi da questo

Unknown column 'p.id_utente' in 'IN/ALL/ANY subquery'
 
ciao
verifica (perchè non possiamo ricordarci tutto) come si chiama nella tabella annunci il campo dell'id dell'utente
perchè se in tabella annunci il campo si dovesse chiamare (es) id_pinco devi mettere

"SELECT * FROM annunci AS p WHERE p.id_pinco= '$id_u' OR p.id_pinco IN ecc....
 
non pretendo questo .. ansie grazie mille per la pazienza ..

l'id nella tabella annunci si chiama id
 
fatto ma il risultato è uguale ...

0 post

PHP:
$id_u=$_SESSION['user_id']; //come detto per scrivere con comodo 
$query="SELECT * FROM annunci AS p WHERE p.id = '$id_u' OR p.id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')";
 
questo è il var_dump

string(224) "SELECT * FROM annunci AS p WHERE p.id = '54' OR p.id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '54' AND r.amico = 'S') OR p.id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '54' AND r.amico = 'S')"

di:

PHP:
$id_u=$_SESSION['user_id']; //come detto per scrivere con comodo 
$query="SELECT * FROM annunci AS p WHERE p.id = '$id_u' OR p.id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')";
var_dump($query);
 
In un precedente script ho avuto problemi per id e ho cambiato in id_annuncio e cosi mi prendeva tutto precisamente.

Fatto questo appunto ti spiego un pochetto com'è fatto il tutto perchè forse o io non capisco quello che dici, o te non capisci quello che dico io :)

Allora io ho una tabella

annunci con i campi id, commento,ts ( timestamp ) e un collegamento alla tabella users con user_id

tabella users

soliti campi id, full_name, user_name ecc ecc

tabella relatioship

id, user_1, user_2, amico ( campo enum con default N modificabile a S


Ora tu continui a dirmi che devo passare l'id

alessandro1997
Non puoi scrivere p.id perché si riferisce al campo che contiene l'ID dell'annuncio. Al posto di id devi inserire il nome del campo che contiene l'ID dell'autore dell'annuncio.

E quindi io devo prenderlo perforza dall'user_id per recuperare il commento di pippo giusto ???

ora io vorrei che il post di pippo puo' vederlo minnye, pluto, paperino ( che sono amici ) ma non gastone ( che dato che sta antipatico a pippo non gli da' amicizia.

Detto questo spero che la cosa sia più chiara ( per il resto scusa ma non sono un mostro di php lo faccio per divertimento e sono un autodidatta, ma sopratutto lo faccio da 6 mesi e quando ho tanto tempo ho 30/35 minuti alla sera di media )

Aiutatemiiiiiiiiiiii questa cosa mi sta facendo impazzire ....
 
Sigh, per l'ultima volta... La query giusta è:
PHP:
$query = "SELECT * FROM annunci AS p WHERE p.user_id = '$id_u' OR p.user_id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.user_id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')";
Non devi cambiare niente. È questa. O funziona o non funziona.
 
inanzitutto infinitamente grazie milleeeeeeeee

Questa sera provo e ti so dire ... e speriamo che dio ce la mandi buona ....
 
Niente da fare ... 0 risultati ...

e questo è il var_dump

string(239) "SELECT * FROM annunci AS p WHERE p.user_id = '54' OR p.user_id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '54' AND r.amico = 'S') OR p.user_id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '54' AND r.amico = 'S')"

PHP:
$id_u=$_SESSION['user_id'];
$query = "SELECT * FROM annunci AS p WHERE p.user_id = '$id_u' OR p.user_id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.user_id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')"; 
 var_dump($query);

Ti puo' aiutare se ti posto le tre tabelle ??? non capisco come mai non funziona ........
 
ecco il tutto

tabella annunci

PHP:
-- phpMyAdmin SQL Dump
-- version 3.3.7
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 18 ott, 2011 at 08:30 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 `annunci`
--

CREATE TABLE IF NOT EXISTS `annunci` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `commento` longtext NOT NULL,
  `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `user_id` int(11) NOT NULL,
  `relationshipid` varchar(25) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=218 ;

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

INSERT INTO `annunci` (`id`, `commento`, `ts`, `user_id`, `relationshipid`) VALUES
(1, 'fhrtyryrtyrtytreyretyrtyrteyrt', '2011-10-15 23:03:44', 54, 'S'),
(2, 'tu5r756e764e5756756', '0000-00-00 00:00:00', 54, '0'),
(39, 'rtyrtyretyrtyret', '2011-10-15 21:55:19', 54, '0'),
(38, 'rtyrtyretyrtyret', '2011-10-15 21:55:03', 54, '0'),
(37, '', '2011-10-15 21:54:59', 54, '0'),
(36, '', '2011-10-15 21:50:42', 54, '0'),
(40, '', '2011-10-15 21:57:01', 54, '0'),
(42, 'yoyuoyoyuyuoyu', '2011-10-15 21:57:16', 54, '0'),
(43, '', '2011-10-15 21:57:21', 54, '0'),
(44, '', '2011-10-15 21:57:39', 54, '0'),
(45, '', '2011-10-15 22:12:31', 54, '0'),
(46, '', '2011-10-15 22:14:10', 54, '0'),
(47, '', '2011-10-15 22:14:13', 54, '0'),
(48, '', '2011-10-15 22:14:49', 54, '0'),
(49, '', '2011-10-15 22:15:08', 54, '0'),
(50, '', '2011-10-15 22:15:57', 54, '0'),
(51, '', '2011-10-15 22:15:59', 54, '0'),
(52, '', '2011-10-15 22:16:09', 54, '0'),
(53, '', '2011-10-15 22:16:21', 54, '0'),
(54, '', '2011-10-15 22:16:23', 54, '0'),
(55, '', '2011-10-15 22:18:41', 54, '0'),
(56, '', '2011-10-15 22:18:43', 54, '0'),
(57, '', '2011-10-15 22:18:51', 54, '0'),
(58, 'hfjkhsdfhsd\r<br>', '2011-10-15 22:19:02', 54, '0'),
(59, 'porca puzzolaaaaa', '2011-10-15 22:19:24', 54, '0'),
(60, 'porca puzzolaaaaa', '2011-10-15 22:20:15', 54, '0'),
(61, 'porca puzzolaaaaa', '2011-10-15 23:11:18', 54, '0'),
(62, 'porca puzzolaaaaa', '2011-10-15 22:21:31', 54, '0'),
(63, 'fdmlsjfijsdiofjsiofjoisahfoihfioshdafoihsdapfsad\r<br>fsdfkopsdjfopsdfopsfsdkfposdf\r<br>sdfksojfopsdfsfsfs\r<br>\r<br>sf\r<br>s\r<br>fs\r<br>d\r<br>\r<br>sdffksdhfiuhsiofhsdoihfoishfoisdhfios', '2011-10-15 22:21:42', 54, '0'),
(182, 'fgfgdfgdfdfdgf', '2011-10-16 21:54:56', 54, ''),
(181, 'fgfgdfgdfdfdgf', '2011-10-16 21:54:24', 54, ''),
(180, 'fgfgdfgdfdfdgf', '2011-10-16 21:53:13', 54, ''),
(179, '', '2011-10-16 21:53:05', 54, ''),
(178, '', '2011-10-16 21:52:39', 54, ''),
(177, '', '2011-10-16 21:52:13', 54, ''),
(176, '', '2011-10-16 21:51:43', 54, ''),
(77, 'ammazzzzzzaaaa', '2011-10-15 23:00:40', 57, '0'),
(175, 'wertewrtertew', '2011-10-16 21:42:42', 54, ''),
(174, 'wertewrtertew', '2011-10-16 21:41:35', 54, ''),
(173, 'reterterterte', '2011-10-16 21:41:27', 54, ''),
(172, 'pippo è uno stronzo\r<br>', '2011-10-16 21:40:13', 54, ''),
(204, '', '2011-10-16 22:05:49', 54, ''),
(203, '', '2011-10-16 22:05:36', 54, ''),
(202, '', '2011-10-16 22:04:42', 54, ''),
(201, '', '2011-10-16 22:04:36', 54, ''),
(200, '', '2011-10-16 22:03:25', 54, ''),
(199, '', '2011-10-16 22:03:21', 54, ''),
(198, '', '2011-10-16 22:02:50', 54, ''),
(197, 'porca trota', '2011-10-16 22:02:27', 54, ''),
(196, 'porca trota', '2011-10-16 22:02:11', 54, ''),
(195, 'sdfasfsfsafsdfsfsafssfdfs', '2011-10-16 22:01:52', 54, ''),
(194, '', '2011-10-16 22:01:41', 54, ''),
(193, '', '2011-10-16 22:01:36', 54, ''),
(192, '', '2011-10-16 22:01:02', 54, ''),
(191, '', '2011-10-16 22:00:59', 54, ''),
(190, '', '2011-10-16 22:00:24', 54, ''),
(189, '', '2011-10-16 21:59:21', 54, ''),
(188, '', '2011-10-16 21:58:54', 54, ''),
(187, '', '2011-10-16 21:58:29', 54, ''),
(186, '', '2011-10-16 21:57:20', 54, ''),
(185, '', '2011-10-16 21:56:41', 54, ''),
(184, '', '2011-10-16 21:56:03', 54, ''),
(183, '', '2011-10-16 21:55:20', 54, ''),
(217, '', '2011-10-16 22:08:48', 54, ''),
(216, '', '2011-10-16 22:08:38', 54, ''),
(215, '', '2011-10-16 22:07:46', 54, ''),
(214, '', '2011-10-16 22:07:45', 54, ''),
(213, '', '2011-10-16 22:07:44', 54, ''),
(212, '', '2011-10-16 22:07:41', 54, ''),
(211, '', '2011-10-16 22:07:37', 54, ''),
(210, '', '2011-10-16 22:07:35', 54, ''),
(209, '', '2011-10-16 22:07:30', 54, ''),
(208, '', '2011-10-16 22:06:45', 54, ''),
(207, '', '2011-10-16 22:06:39', 54, ''),
(206, '', '2011-10-16 22:06:33', 54, ''),
(205, '', '2011-10-16 22:06:26', 54, ''),
(152, 'hsfusdhfiusdhiufsdhfiushdufishdfuishdiufs+sd\r<br>fsdpofopdsfs\r<br>dfasjofpjlkvndlmglkfsjgl\r<br>\r<br>xlòcgjokxcjvklxcjv\r<br>xcmvlcxvlkxcjvlxjlvòxjclòvjxc', '2011-10-16 20:13:52', 54, ''),
(153, 'hsfusdhfiusdhiufsdhfiushdufishdfuishdiufs+sd\r<br>fsdpofopdsfs\r<br>dfasjofpjlkvndlmglkfsjgl\r<br>\r<br>xlòcgjokxcjvklxcjv\r<br>xcmvlcxvlkxcjvlxjlvòxjclòvjxc', '2011-10-16 20:13:58', 54, ''),
(154, 'hsfusdhfiusdhiufsdhfiushdufishdfuishdiufs+sd\r<br>fsdpofopdsfs\r<br>dfasjofpjlkvndlmglkfsjgl\r<br>\r<br>xlòcgjokxcjvklxcjv\r<br>xcmvlcxvlkxcjvlxjlvòxjclòvjxc', '2011-10-16 20:14:15', 54, ''),
(163, 'porca vacchetta\r<br>ù\r<br>', '2011-10-16 20:23:26', 54, ''),
(166, 'gjgjgjgjghjgjghjgh', '2011-10-16 20:24:51', 54, ''),
(168, 'provacelllllooo\r<br>', '2011-10-16 21:34:59', 54, ''),
(169, 'provacelooooooos<dosaodsaodosa', '2011-10-16 21:36:13', 54, ''),
(170, 'provacelooooooos<dosaodsaodosa', '2011-10-16 21:36:43', 54, ''),
(171, 'pippo è uno stronzo\r<br>', '2011-10-16 21:38:17', 54, '');

tabella relationship

PHP:
-- phpMyAdmin SQL Dump
-- version 3.3.7
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 18 ott, 2011 at 08:31 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=31 ;

--
-- 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', 'N'),
(28, '55', '58', 'N'),
(29, '55', '54', 'S'),
(30, '57', '58', 'N');


tabella users

PHP:
-- phpMyAdmin SQL Dump
-- version 3.3.7
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generato il: 18 ott, 2011 at 08:34 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 `users`
--

CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `md5_id` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `full_name` tinytext COLLATE latin1_general_ci NOT NULL,
  `user_name` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `user_email` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `user_level` tinyint(4) NOT NULL DEFAULT '1',
  `pwd` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `address` text COLLATE latin1_general_ci NOT NULL,
  `country` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `tel` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `fax` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `website` text COLLATE latin1_general_ci NOT NULL,
  `date` date NOT NULL DEFAULT '0000-00-00',
  `users_ip` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `approved` int(1) NOT NULL DEFAULT '0',
  `activation_code` int(10) NOT NULL DEFAULT '0',
  `banned` int(1) NOT NULL DEFAULT '0',
  `ckey` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  `ctime` varchar(220) COLLATE latin1_general_ci NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  UNIQUE KEY `user_email` (`user_email`),
  FULLTEXT KEY `idx_search` (`full_name`,`address`,`user_email`,`user_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=63 ;

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

INSERT INTO `users` (`id`, `md5_id`, `full_name`, `user_name`, `user_email`, `user_level`, `pwd`, `address`, `country`, `tel`, `fax`, `website`, `date`, `users_ip`, `approved`, `activation_code`, `banned`, `ckey`, `ctime`) VALUES
(54, '', 'admin', 'admin', 'stefa@gmail.com', 5, '01b7db6f3d9c872d639709a57f7f04ac4fd953cfac42f7e3a', 'admin', 'Italia', '4433093999', '', 'www.pipripicchio.it', '2010-05-04', '', 1, 0, 0, '0w1de9h', '1318958484'),
(55, '', 'pippo', '300', 'pippo@pippo.it', 1, 'c871024abff6025ca2a29773c5684e1cc5f27c15ed5341a00', '', 'italy', '02-000000', '02-4646464646', 'http://www.pippo.it', '2011-08-06', '', 1, 0, 0, '', ''),
(56, '9f61408e3afb633e50cdf1b20de6f466', 'forse si', 'minnye', 'minnye@minnye.it', 1, '9001b8819f823d412c2de6ee2726c17504092094282988ffa', '', 'Italy', '333-5575757', '02-40348803', 'http://www.minnye.it', '2011-08-09', '127.0.0.1', 1, 9180, 0, 'rt4izeo', '1315145417'),
(57, '', 'Paperino', 'paperino', 'papa@pape.it', 1, '077f388cfb8f5c9f688d620d948b7853c643e052b3ad08209', '', '', '', '', '', '2011-09-03', '', 1, 0, 0, '', ''),
(62, '44f683a84163b3523afe57c2e008bc8c', 'stefanino', 'stefanino3', 'bdfkajhfiahd@jdbfd.it', 1, '99e269a6acd6b4009e4e21729edfcfa04860a378c677ebf91', 'dsfsdfsdfsdfsfsd', 'Albania', '45454545645465', '', '', '2011-10-13', '::1', 1, 1742, 0, '', ''),
(58, '', 'Miriam alba', 'miriam alba', 'fsfds@dfsdfs.it', 1, '1b0747b56e374b24a4feafdbdb34d6bd910c8205c4a3f64e3', '', '', '', '', '', '2011-10-05', '', 1, 0, 0, '', ''),
(59, '093f65e080a295f8076b1c5722a46aa2', 'Miriam Alba', 'MiriamAlba', 'fnlkfldk@fdfd.it', 1, '7bc31a36e69f4519fe13f33c236266391877929a67d8caaee', 'sdfsdfsddsfsd', 'Albania', '5464565464', '', '', '2011-10-05', '::1', 1, 9404, 0, '', ''),
(60, '072b030ba126b2f4b2374f342be9ed44', 'Miriam Alba', 'miriamuzza', 'fjksdhfjkshaf@gdsfds.it', 1, 'd6d0966965eb1b041d1af599aa989d3a59f13d3f76e30fe3d', 'dsgdfgdgdgdsgd', 'Anguila', '6455464545645', '', '', '2011-10-05', '::1', 0, 1309, 0, '', ''),
(61, '', 'stefano', 'stefano', 'ste@dfd.it', 1, '911e7ec7d73b084e7e486698f9e61b598e5f4edcb59c361f8', '', '', '', '', '', '2011-10-13', '', 1, 0, 0, '', '');

pagina bacheca.php

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>
      

  
   <?php echo $_SESSION['user_id'];?>

<br />
<br />
<br />
<?php

$id_u=$_SESSION['user_id'];
$query = "SELECT * FROM annunci AS p WHERE p.user_id = '$id_u' OR p.user_id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.user_id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')"; 
 var_dump($query);  
 
 
while ($joke = mysql_fetch_array($query)) { 


$user_id = $joke['user_id'];    
$user_name = $joke['user_name'];
$commento = $joke['commento'];


echo "$user_name<br /><br />"; 

 echo "$commento<br /><br />"; 
 
 } 




?>


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

</body>
</html>

Ti ho postato tutto speriamo che riesci a risolvere .... :(
 
ciao
manca qualcosa

PHP:
$id_u=$_SESSION['user_id']; 
$query = "SELECT * FROM annunci AS p WHERE p.user_id = '$id_u' OR p.user_id IN (SELECT user_1 FROM relationship AS r WHERE r.user_2 = '$id_u' AND r.amico = 'S') OR p.user_id IN (SELECT user_2 FROM relationship AS r WHERE r.user_1 = '$id_u' AND r.amico = 'S')";  
 var_dump($query);   
$ris=mysql_query($query);//*******!!!!!!!!!!!!*******non vedo questa istruzione
  
while ($joke = mysql_fetch_array($ris)) {  //$ris al posto di $query
//....
poi dopi altre osservazioni
 
Ultima modifica:

Discussioni simili