Aqui el código completo:
Código PHP:
<?php
include "lib/conectar.php";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="en-us" http-equiv="Content-Language">
<title>Tutorials</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(".follow").click(function(){
var element = $(this);
var I = element.attr("id");
var info = 'id=' + I;
$("#loading").html('<img src="loader.gif" align="absmiddle"> loading...');
$.ajax({
type: "POST",
url: "lib/follow.php",
data: info,
success: function(){
$("#loading").ajaxComplete(function()
{
}).slideUp();
$('#follow'+I).fadeOut(200).hide();
$('#remove'+I).fadeIn(200).show();
}
});
return false;
});
});
</script>
<script type="text/javascript">
$(function() {
$(".remove").click(function(){
var element = $(this);
var I = element.attr("id");
var info = 'id=' + I;
$("#loading").html('<img src="loader.gif" align="absmiddle"> loading...');
$.ajax({
type: "POST",
url: "lib/remove.php",
data: info,
success: function(){
$("#loading").ajaxComplete(function()
{}).slideUp();
$('#remove'+I).fadeOut(200).hide();
$('#follow'+I).fadeIn(200).show();
}
});
return false;
});
});
</script>
</head>
<body>
<?php
$conn = conectar();
$i = 0;
$sql1 = "SELECT * FROM usuarios U WHERE NOT exists (SELECT * FROM amistades A where A.id_usuario_a = U.id_usuario and A.id_usuario_b = '1' or A.id_usuario_a = '1' and A.id_usuario_b = U.id_usuario or U.id_usuario='1')";
$resultado1 = mysql_query($sql1, $conn) or die(mysql_error());
?>
<table align="center">
<tbody>
<tr>
<td width='455' valign="top">
<h3>Click <span style="color:#006699">Follow</span> and <span style="color:#006699">remove</span> Buttons</h3>
</td></tr>
<tr>
<td width='455' valign="top">
<div id="loading"></div>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php while($row1 = mysql_fetch_assoc($resultado1)){ ?>
<tr class="record">
<?php
$foto_perfil = "imagenes/'".$row1['id_usuario']."'/'".$row1['id_usuario']."'.jpg";
$default_perfil = "imagenes/0/perfil.jpg";
if (file_exists($foto_perfil)) {?>
<td width="51"><img src="<?php echo $foto_perfil?>" width="50" height="50"/></td>
<?php
} else {
?>
<td width="51"><img src="<?php echo $default_perfil?>" width="50" height="50"/></td>
<?php
}?>
<td width="7" align="right" ></td>
<td width="376" class="content">
<strong ><a href="http://twitter.com/9lessons" style="color:#d02b55;"><?php echo $row1['nombre']; ?></a></strong>
Srinivas Tamada. <br />
<div id="follow1"><a href="#" class="follow" id="<?php $row1['id_usuario']?>"><span class="follow_b"> Follow </span></a></div>
<div id="remove1" style="display:none"><span class="youfollowing_b"> You Following </span><a href="#" class="remove" id="<?php $row1['id_usuario']?>"><span class="remove_b"> remove </span></a></div>
</td>
</tr>
<?php $i++;
}?>
</table>
</div>
</td></tr>
</tbody>
</table>
</div>
</body></html>
Aqui dejo solo la parte de php:
Código PHP:
<?php
$conn = conectar();
$i = 0;
$sql1 = "SELECT * FROM usuarios U WHERE NOT exists (SELECT * FROM amistades A where A.id_usuario_a = U.id_usuario and A.id_usuario_b = '1' or A.id_usuario_a = '1' and A.id_usuario_b = U.id_usuario or U.id_usuario='1')";
$resultado1 = mysql_query($sql1, $conn) or die(mysql_error());
?>
<table align="center">
<tbody>
<tr>
<td width='455' valign="top">
<h3>Click <span style="color:#006699">Follow</span> and <span style="color:#006699">remove</span> Buttons</h3>
</td></tr>
<tr>
<td width='455' valign="top">
<div id="loading"></div>
</td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php while($row1 = mysql_fetch_assoc($resultado1)){ ?>
<tr class="record">
<?php
$foto_perfil = "imagenes/'".$row1['id_usuario']."'/'".$row1['id_usuario']."'.jpg";
$default_perfil = "imagenes/0/perfil.jpg";
if (file_exists($foto_perfil)) {?>
<td width="51"><img src="<?php echo $foto_perfil?>" width="50" height="50"/></td>
<?php
} else {
?>
<td width="51"><img src="<?php echo $default_perfil?>" width="50" height="50"/></td>
<?php
}?>
<td width="7" align="right" ></td>
<td width="376" class="content">
<strong ><a href="http://twitter.com/9lessons" style="color:#d02b55;"><?php echo $row1['nombre']; ?></a></strong>
Srinivas Tamada. <br />
<div id="follow1"><a href="#" class="follow" id="<?php $row1['id_usuario']?>"><span class="follow_b"> Follow </span></a></div>
<div id="remove1" style="display:none"><span class="youfollowing_b"> You Following </span><a href="#" class="remove" id="<?php $row1['id_usuario']?>"><span class="remove_b"> remove </span></a></div>
</td>
</tr>
<?php $i++;
}?>
</table>
</div>
</td></tr>
</tbody>
</table>
</div>