Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/11/2011, 05:04
edyuin
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
sistema de amigos php

Hola estoy intentando desarrollar un sistema de agregar usuario el problema es que nose si voy bien y como hacer el boton de agregar amigos y que este se quite cuando el amigo ya le mandaste peticion, os dejo las estructuras y haber si me podeis ayudar:
tabla amigos:
CREATE TABLE `amigos` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_logueado` text COLLATE latin1_general_ci NOT NULL,
`id_amigo` text COLLATE latin1_general_ci NOT NULL,
`Estado` text COLLATE latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=2 ;

nose como hacer un if de que si el usuario no se encuentra registrado en esta base me mande el boton como hago esto tengo esto pero no funciona:

Código PHP:
<?php
 
include("header.php"); 

if (!isset(
$_SESSION['logueado_usuario'])) { 
    include (
"../login.php");  
echo 
"<a href='../registro.php'>Registrarse</a>" ;} 
    else {  
    
$nombre =$_SESSION['logueado_nombre']; 
    
$id_usuario=$_SESSION['logueado_id']; 
?> 
<link href="../Css/estilo.css" rel="stylesheet" type="text/css">
<?php
include("privados/config.php");
$registros=mysql_query("select * from usuarios ORDER BY id desc "$conexion)or
  die(
"Problemas en el select:".mysql_error());
 
$i=0;
 while(
$reg=mysql_fetch_array($registros))
?>
 <img src="<?php echo "".$reg['imagen']. "";?>" />
<?php
echo "".$reg['nombre']."<br>" ;
 
?>
<?php
$consulta
="select Estado from amigos where id_amigo='$reg[id]'";
echo 
"$consulta <br>";//ESTO PEGALO EN TU PHPMYADMIN PARA SABER CUANTOS REGISTROS TRAE
$ejecuta=mysql_query($consulta) or  die("Problemas en el select:".mysql_error());
$cantidad=mysql_num_rows($ejecuta);
while(
$cons=mysql_fetch_array($ejecuta))
{
    echo 
"$cantidad<br>";
    if(
$cons['Estado']=="pendiente")
    {
         echo 
"Ya mandaste peticion 1";
        

    }
    elseif (
$cons['Estado']!="pendiente")
    {
       echo 
'<div class="amigos">
 <form action="agregara.php" method="post">
 <input type="hidden" name="id" value="'
.$reg['id'].'">
 <input type="submit" value="Agregar Amigos">
 </form>
 </div>'

 echo 
"0";
    }
    
}

?>




 


 <div id="consulta"></div>
 <? ?>
 
 
 <?php ?>