Hi...
I've been working on finding a solution for this for the last couple of days, and it's got me stumped.
I'm working with a PHPBB Forum, where I'm getting the user data, and a secondary table I've created called Missions within the PHPBB database for some other data. What I need to be able to do is have four different possibilities once a user (or "pilot" in this case) logs into the website.
- The pilot hasn't flown a single combat mission OR logged onto the forum once.
- The pilot has logged into the forum but HAS NOT flown a combat mission.
- The pilot has flown a combat mission but HAS NOT logged onto the forum.
- The pilot has logged onto the forum AND flown a combat mission.
So far, when I try my code that I have pasted below (after many frustrating hours changing it around), I get result #1 almost all the time, regardless if the pilot has logged onto the forum or flown a combat mission. Help!
Here's my admittedly hacked and slashed code I've been working with...
$user = $_SESSION['username'];
mysql_connect('localhost', '*', '*');
mysql_select_db('database');
$query = "SELECT user_lastvisit FROM phpbb_users WHERE username = '$user' AND user_lastvisit != 0";
$res = mysql_query($query) or die(mysql_error());
$lastvisit = mysql_num_rows($res);
while($row = mysql_fetch_array($res)) {
if ($lastvisit = 0) {
$forum_date = "0";
} else {
$forum_date = date("M jS, Y", $row['user_lastvisit']);
}
}
$mis = "SELECT mission_date FROM missions WHERE callsign = '$user'";
$results = mysql_query($mis) or die(mysql_error());
$mission_date = mysql_num_rows($results);
while($rows = mysql_fetch_array($results)) {
$mission = $rows['mission_date'];
if (($mission_date == 0) || ($forum_date == 0)) {
$display_block = "
<p align=\"center\"><font size=\"2\"><b>Welcome,<br>herr $username!</b></font></p>
<p align=\"center\"><font size=\"2\">You have not<br>flown any Combat<br>Missions as yet.</font></p>
<p align=\"center\"><font size=\"2\">You have not<br>logged into the<br>JG26 Forums yet.</font></p>";
} else if ($forum_date != 0) {
$display_block = "
<p align=\"center\"><font size=\"2\"><b>Welcome,<br>herr $username!</b></font></p>
<p align=\"center\"><font size=\"2\">You have not<br>flown any Combat<br>Missions as yet.</font></p>
<p align=\"center\"><font size=\"2\">Your last visit<br>to the JG26<br>Forum was on<br><font color=#FFCC00>$forum_date</font>.</p>";
} else if ($mission_date != 0) {
$display_block = "
<p align=\"center\"><font size=\"2\"><b>Welcome,<br>herr $username!</b></font></p>
<p align=\"center\"><font size=\"2\">Your last Combat<br>Mission was on<br><font color=#FFCC00>$mission</font>.</p>
<p align=\"center\"><font size=\"2\">You have not<br>logged into the<br>JG26 Forums yet.</font></p>";
} else {
$display_block = "
<p align=\"center\"><font size=\"2\"><b>Welcome,<br>herr $username!</b></font></p>
<p align=\"center\"><font size=\"2\">Your last Combat<br>Mission was on<br><font color=#FFCC00>$mission</font>.</p>
<p align=\"center\"><font size=\"2\">Your last visit<br>to the JG26<br>Forum was on<br><font color=#FFCC00>$forum_date</font>.</p>";
}
}
I'm sure some of the syntax is wrong in there because of how much I've tried to change the results tree in the if/else statements.
Thanks....