<td> <hr> </td> 
				<td> <hr> </td> 
				<td> <hr> </td> 
			</tr>
<?php 
$user_id = $_SESSION["user_id"];
include 'mysql.php';
if ($resid) {
    $count = MySQLi_Query($resid, "select frnd_two_id from are_friends where frnd_one_id = {$user_id} union select frnd_one_id from are_friends where frnd_two_id = {$user_id}");
    echo "<tr align='center'> <td colspan='5'>Your Friends:- </td> </tr> <tr align='center'> <td colspan='5'><table align='center' >";
    echo " <table align='center' cellspacing='5' cellpadding='5'> \n\t\t\t\t<tr> <th> Name: </th> <th> Email: </th> <th> Gender: </th> </tr>";
    while (($rows = MySQLi_Fetch_Row($count)) == True) {
        $query = "select name,email,gender from students where id = {$rows['0']} ";
        $result = MySQLi_Query($resid, $query);
        if ($result) {
            while (($rows = MySQLi_Fetch_Row($result)) == True) {
                echo "<tr align='center'>";
                echo "<td> {$rows['0']} </td> <td> {$rows['1']} </td> <td> {$rows['2']} </td>";
                echo "</tr>";
            }
        }
    }
    echo "</table> ";
}
?>
		</table>
			<footer align='center'>
			&copy; All Rights Reserved.	
			</footer>
</body>
</html>		
示例#2
0
			
			<?php 
//Session_start();
if (isset($_SESSION["user_id"])) {
    $id = $_SESSION["user_id"];
    $query = "select * from messages where receiver_id=" . $id . " order by id desc";
    $res_id = MySQLi_Connect('localhost', 'root', '@connectme', 'shangout');
    if (MySQLi_Connect_Errno()) {
        echo "<tr align='center'> <td colspan='5'> Failed to connect to MySQL </td> </tr>";
    } else {
        $result = MySQLi_Query($res_id, $query);
        $data = MySQLi_Fetch_Row($result);
        if ($data) {
            $query = "select name,email from students where id=" . $data[1] . "";
            $sender = MySQLi_Query($res_id, $query);
            $sender = MySQLi_Fetch_Row($sender);
            //if($data) {
            echo "<tr align='center'> <td colspan='5'> <table cellpadding='4' cellspacing='5' width='100%' style='table-layout:fixed'> <col width='100%'> ";
            echo "<td>From:- <font color='blue'>" . $sender[0] . " </font> [" . $sender[1] . "] </td> </tr>";
            echo "<tr> <td style='word-wrap:break-word'>Message:-" . $data[3] . "</td> </tr>";
            echo "</table> </td> </tr>";
        } else {
            echo "<tr align='center'> <td colspan='5'> <font color='lightblue'> No Messages! </font> </td> </tr>";
        }
        MySQLi_Close($res_id);
    }
} else {
    echo "<tr align='center'> <td colspan='5'> <font color='red'> Sorry, You not Logged in! </font> Login again:- <a href='login.php'>Login</a> </td> </tr>";
}
?>
		</table>
     return $data;
 }
 $name = sec($_POST["n1"]);
 $email = sec($_POST["e1"]);
 $age = sec($_POST["a1"]);
 $gender = sec($_POST["g1"]);
 $password = sec($_POST["p1"]);
 //$query="INSERT INTO studs VALUES('$name','$email',$age);";
 //MySQL Magic :D
 //Getting Resource ID
 $res_id = MySQLi_Connect('localhost', 'root', '@connectme', 'shangout');
 if (MySQLi_Connect_Errno()) {
     echo "<tr align='center'> <td colspan='5'> Failed to connect to MySQL </td> </tr>";
 } else {
     $check_email = MySQLi_Query($res_id, "select name from students where email='" . $email . "'");
     $r_email = MySQLi_Fetch_Row($check_email);
     if ($r_email) {
         echo "<tr align='center'> <td colspan='5'> <font color='red'> Email already Registered, Registration Failed!  </font>  </td> </tr>";
     } else {
         $count = MySQLi_Query($res_id, "select (max(id)+1) as count  from students");
         $count_id = MySQLi_Fetch_Assoc($count);
         if ($count_id["count"]) {
             $query = "insert into students values (" . $count_id["count"] . ",'{$name}','{$email}',{$age},'{$gender}','{$password}')";
         } else {
             $query = "insert into students values (1,'{$name}','{$email}',{$age},'{$gender}','{$password}')";
         }
         $res = MySQLi_Query($res_id, $query);
         if ($res) {
             echo "<tr align='center'> <td colspan='5'> <font color='green'> Registration Successful! </font> You may login now from here:- <a href='login.php'>Login</a></td> </tr>";
         } else {
             echo "<tr align='center'> <td colspan='5'> <font color='red'> Registration Failed! </font> </td> </tr>";
                 if ($res4[0] == 0 and $res4[1] == 0) {
                     $flo = 1;
                 } else {
                     $flo = 2;
                 }
             }
             //START:- Exclude those who are engaged and self;
             $query2 = "select status from are_friends where frnd_one_id=" . $_SESSION["user_id"] . " and frnd_two_id=" . $rows[0] . "";
             $query3 = "select status from are_friends where frnd_one_id=" . $rows[0] . " and frnd_two_id=" . $_SESSION["user_id"] . "";
             $result2 = MySQLi_Query($res_id, $query2);
             $result3 = MySQLi_Query($res_id, $query3);
             if ($result2 == true) {
                 $res2 = MySQLi_Fetch_Row($result2);
             }
             if ($result3 == true) {
                 $res3 = MySQLi_Fetch_Row($result3);
             }
             if ($rows[0] == $_SESSION["user_id"]) {
                 $flori = 1;
             } else {
                 $flori = 2;
             }
             if ($res2[0] == 1 or $res3[0] == 1 or $flo == 1 or $flori == 1) {
             } else {
                 echo "<tr align='center'> <td align='left'>" . $rows[1] . "</td> <td align='left'> <form method='POST' action='sendfr.php'>\n\t\t\t\t\t\t\t<input type='hidden' name='h1' value='" . $rows[0] . "'>\n\t\t\t\t\t\t\t<input type='hidden' name='h2' value='" . $rows[1] . "'>\n\t\t\t\t\t\t\t<input type='submit' name='sfr' value='Send Request'>\n\t\t\t\t\t\t\t</form></td> </tr>";
             }
         }
     }
     echo "</table></td></tr>";
 }
 if ($f < 2) {