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