Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

What am I doing wrong?! (While and If Statements)

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

What am I doing wrong?! (While and If Statements)

Postby LVPHPNewbie » Thu Jun 06, 2013 8:04 am

I can't figure out how to create a while statement inside an if-statement. I am trying to create a php page that runs a table for tickets that clients have entered for assistance. My goal is to have each row of the table be checked to see if the ticket is currently assigned to the user logged in or to someone else. This is what I attempted:

Code: Select all
echo "Welcome <B>" .$_SESSION['loggedinuser']. "</B> !<BR><BR>";

echo "<BR><BR><HR WIDTH=\"60%\" SIZE=\"3\"> <BR><B><CENTER>IRT Message History</CENTER></B><BR>";
$result = mysql_query("SELECT * FROM history WHERE Date > NOW() - INTERVAL 14 DAY ORDER BY Date DESC");
$num_rows = mysql_num_rows($result);
echo "<CENTER><table border cellpadding=3><TR><TH>ID</TH><TH><B>Date</B></TH><TH><B>Type of IRT</B></TH><TH><B>Sent By</B></TH><TH><B>Operator</TH></B><TH><B>BAN/Application</TH></B><TH><B>Assigned</TH></B></TR>";
while($info = mysql_fetch_assoc($result))
echo "<tr><Td>".$info['ID'] . "</td> <td>"; $info['Date']." </Td><TD>" .$info['Type']. "</Td><TD>" .$info['Sender']. "</Td><TD>" .$info['SCA']. "</Td><TD>" .$info['BAN']. "</Td><TD>";
$AssignedTo=$info['Assigned'];
if ($AssignedTo == $MyAssignedID)
echo "<B>Me</B> </Td></TR>";
end if;
if ($AssignedTo != $MyAssignedID)
echo "<a href=\"logout.php\">Assign to me</A></Td></TR>";
end if;
end while;
echo "</table></center>";

This is the error I keep getting

Code: Select all
Parse error: syntax error, unexpected T_IF in C:\AppServ\www\beta\queues\IRT\admin.php on line 34

Line 34 would be the red text part below:

if ($AssignedTo == $MyAssignedID)
echo "<B>Me</B> </Td></TR>";
end if;

Any ideas?
LVPHPNewbie
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jun 06, 2013 7:57 am

Re: What am I doing wrong?! (While and If Statements)

Postby LVPHPNewbie » Thu Jun 06, 2013 8:28 am

I updated the code to what is below

Code: Select all
echo "Welcome <B>" .$_SESSION['creditrep']. "</B> !<BR><BR>";

echo "<BR><BR><HR WIDTH=\"60%\" SIZE=\"3\"> <BR><B><CENTER>IRT Message History</CENTER></B><BR>";
$result = mysql_query("SELECT * FROM history WHERE Date > NOW() - INTERVAL 14 DAY ORDER BY Date DESC");
$num_rows = mysql_num_rows($result);
echo "<CENTER><table border cellpadding=3><TR><TH>ID</TH><TH><B>Date</B></TH><TH><B>Type of IRT</B></TH><TH><B>Sent By</B></TH><TH><B>Operator</TH></B><TH><B>BAN/Application</TH></B><TH><B>Assigned</TH></B></TR>";
while($info = mysql_fetch_assoc($result))
{
echo "<tr><Td>".$info['ID'] . "</td> <td>"; $info['Date']." </Td><TD>" .$info['Type']. "</Td><TD>" .$info['Sender']. "</Td><TD>" .$info['SCA']. "</Td><TD>" .$info['BAN']. "</Td><TD>";
$AssignedTo=$info['Assigned'];
if ($AssignedTo == $MyAssignedID)
{
echo "<B>Me</B> </Td></TR>";
}
if ($AssignedTo != $MyAssignedID)
{
echo "<a href=\"logout.php\">Assign to me</A></Td></TR>";
}
}
echo "</table></center>";


Now my output is a little off and not lining up correctly. See attachment,
Attachments
IRT_Picture.JPG
Example of Output
IRT_Picture.JPG (11.06 KiB) Viewed 295 times
LVPHPNewbie
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jun 06, 2013 7:57 am

Re: What am I doing wrong?! (While and If Statements)

Postby LVPHPNewbie » Thu Jun 06, 2013 8:42 am

And I got it to work. Darn syntax errors. :-x
LVPHPNewbie
New php-forum User
New php-forum User
 
Posts: 3
Joined: Thu Jun 06, 2013 7:57 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.