<?php
// Recupera las peticiones de amistad enviadas al usuario identificado
$con=mysql_connect("localhost","root","opsivir")
 or die("Error: ".mysql_error());
$name = 'prueba';
$db = mysql_select_db($name,$con)
 or die("Error: ".mysql_error());

$user = mysql_escape_string($_GET["user"]);  
$result = mysql_query("SELECT *FROM peticiones WHERE (user2 = '$user')") or die("Error: ".mysql_error());


//Recorre los elementos de la consulta y muestra la inoramcion de la peticion
while($row = mysql_fetch_array($result))
  {
  $files = array();
  $user1 = $row['user1'];
  $files = scandir("C:/xampp/htdocs/tfg/uploads/".$user1);
  $num = count($files);
  if((count($files)-2)==0){
  		$path = "img/imgpiso.bmp";
  }else{
  		$path = "http://kl0d.no-ip.biz/tfg/uploads/".$user1."/".$files[0];
  }
  
  echo "<div class=\"marcos\">
		  <table border=\"0\" style=\"width:100%\">
		  	<tr>
		  		<td><center><img src='$path' WIDTH=60% HEIGHT=20% ></center></td>
				<td>				 
				  	<table border=\"0\" style=\"width:100%\" class=\"letra\">
						<tr>
						  <td>Request from:</td>
						  <td>$user1</td>
						</tr>
						<tr>
						<td><input type=\"button\" class=\"botonVuelos\" name=\"$user1\" id=\"$user1\" value=\"Accept\" onClick=\"addFriend('$user1')\"></td>
						<td><input type=\"button\" class=\"botonVuelos\" name=\"$user1\" id=\"$user1\" value=\"Decline\" onClick=\"deleteFriend('$user1')\"></td>		
						</tr>			
					</table>
				</td>
			</tr>
			</table>
		</div>
	<br></br>";
  }

mysql_close($con);
?>