what im trying to do is something for a support ticket system.
i have the support ticket's initial message coming up (the one the user posted) and now i want to display the replys below that, and obviously it will look like this:
Initial Message
Admin Reply
User Reply
Admin Reply
and so on.
but i cant figure out how i would get the replys outputting in the right order.
i got as far as a for each but then stopped realizing it was inside a while loop, and then got more confused when i noticed this would go horibly wrong.
how would you do this?
so far i have this (up to the point where i stopped).
Code: Select all
if($action == 'view_tickets'){
$ticket_id = (int)$_GET['ticket'];
$ticket_get = @mysql_query("SELECT ticket_title, ticket_content FROM tickets WHERE ticket_id='$ticket_id';");
$admin_ticket_replys = @mysql_query("SELECT * FROM admin_ticket_replys ORDER BY admin_reply_date");
$user_ticket_replys = @mysql_query("SELECT * FROM user_ticket_replys ORDER BY user_reply_date");
while($ticket_info = mysql_fetch_array($ticket_get)
&& mysql_fetch_array($user_ticket_replys)
&& mysql_fetch_array($admin_ticket_replys)){
$ticket_title = $ticket_info['ticket_title'];
$ticket_content = $ticket_info['ticket_content'];
echo "<p>(<a title=\"Back to your tickets\" href=\"". $_SERVER['PHP_SELF'] ."?action=view\">Back to your tickets</a>)<br /><br />
<strong>Ticket Title:</strong><br />
$ticket_title<br /><br />
<strong>Original Message:</strong><br />
$ticket_content</p>";
foreach()
}bit of a mess aye? as i said, i got the initial message showing up fine.
here are the tables regarding this:
TICKETS(contains all details):
Field Type Collation Null Key Default Extra Privileges Comment
----------------- ----------- ----------------- ------ ------ ------- -------------- -------------------- -------
ticket_id int(11) (NULL) NO PRI (NULL) auto_increment select,insert,update
ticket_title varchar(35) latin1_swedish_ci YES (NULL) select,insert,update
ticket_user int(11) (NULL) NO select,insert,update
ticket_content text latin1_swedish_ci YES (NULL) select,insert,update
ticket_open int(11) (NULL) YES 1 select,insert,update
ticket_date date (NULL) YES (NULL) select,insert,update
ticket_fixed_date date (NULL) YES (NULL) select,insert,update
ticket_replied int(11) (NULL) YES 1 select,insert,update
USER_TICKET_REPLYS(contains user replies)
Field Type Collation Null Key Default Extra Privileges Comment
-------------------- ------- ----------------- ------ ------ ------- ------ -------------------- -------
user_ticket_reply_id int(11) (NULL) NO select,insert,update
user_replys text latin1_swedish_ci YES (NULL) select,insert,update
user_reply_time time (NULL) YES (NULL) select,insert,update
user_reply_date date (NULL) YES (NULL) select,insert,update
and ADMIN_TICKET_REPLYS(contains admin replys)
Field Type Collation Null Key Default Extra Privileges Comment
--------------------- ------- ----------------- ------ ------ ------- ------ -------------------- -------
admin_ticket_reply_id int(11) (NULL) NO select,insert,update
admin_replys text latin1_swedish_ci YES (NULL) select,insert,update
admin_reply_time time (NULL) YES (NULL) select,insert,update
admin_reply_date date (NULL) YES (NULL) select,insert,update
any help highly appreciated on this one
edit: ohh no, the tables have gone messed up, if anybody cant make any sense of them let me know and ill print screen them.
thanks.