- On Who’s Online page (useronline.php), be able to see current online
users (except for your ownself) → This is done. - Be able to select the online user→ Clicking on particular online
user sends a play game request to that selected online user and
takes the current online user to playgame.php page while waiting for
that selected online user’s response whether he wants to play or not - If the selected user is already busy playing with someone else, show
the notification that selected online user is busy playing with some
other user.
Below code saves as useronline.php which shows All Current Online Users except the logged in user himself (After all You don't see yourself online unless you view your profile from someother account
<?php include( 'connection.php'); include( 'session.php'); echo "<spam style ='margin-left:10px'>Not ".$login_session. " ".$login_lname. " ? We would appreciate if you ".
"<a style='text-decoration:none' href='logout.php'><strong> log out </strong></a> ". " right away!</span>"; $online_users_query="SELECT * from users WHERE online_status='1'" ; $offline_users_query="SELECT * from users WHERE online_status='0'" ; $result=$ dbc ->query($online_users_query); $result1 = $dbc -> query($offline_users_query); if ($result -> num_rows > 0) { ?>
fetch_assoc()) { if (($row['id']) != $login_id) { echo " "."
Clicking on Online user takes me to playgame.php where selected online user is shown. The code is as below:
<span style="color:white;background-color:red;border-radius: 5px;padding:0% 1%;">
<?php
//error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
/*$query=mysql_connect("localhost","root","");
mysql_select_db("zillionsparks_db",$query);
if(($row['id']) != $login_id)
{
$id=$_GET['id'];
$query1=mysql_query("select * from users where id='$id'");
$query2=mysql_fetch_array($query1);
echo "Your Partner: ".$query2['id'];
}*/
$ses_sql=mysql_query("SELECT * from users WHERE online_status='1'", $connection);
$row = mysql_fetch_assoc($ses_sql);
if((($row['id']) != $login_id)) {
echo "Your Partner: ".$row['id'];
}
?>
</span>
I have tested this code on localhost MySQL Database from different browser on my laptop.
This code does show online user B if user A selects user B to play with from chrome browser, but if, in turn, user B selects user A, user A is not shown as partner on playgame.php page.
0 comments:
Post a Comment