Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Refresh information on submit
Old 07-13-2010, 09:29 PM Refresh information on submit
Skilled Talker

Posts: 83
Trades: 0
Hi all,

I've created a support ticket system for users that have questions while on my site. The questions are stored inside a database. On my admin page, I access this information, and show it to the screen, where I can then answer the question. It all works great, except one problem.

The unanswered question that displays on the top of the page is supposed to be replaced with a new question upon hitting Submit. Also, the number of support tickets left is supposed to update (where it says Number of Tickets

What do I need to change to my code to make it update the new question and new total of tickets when I hit submit?

Thanks.

PHP Code:
<?php
session_start
();

include_once(
'../inc/nav.php');

$submit $_POST['submit'];
if(isset(
$_SESSION['username'])){  

include_once(
'../inc/connect.php');

$supportsql "SELECT * FROM `support` WHERE `answered`='no' ORDER BY `date` DESC"

$result mysql_query($supportsql);
$row mysql_fetch_assoc($result);
$num mysql_num_rows($result); 

$username $row['username'];



$i 0;
while (
$i $num) {

$user mysql_result($result,$i,"username");
$message mysql_result($result,$i,"message");
$number mysql_result($result,$i,"number");
// echo "<br /><div align='center' id='question'><strong>".ucfirst($user)."<br /></strong>".$message."<br /></div>";

$i++;
}
echo 
"<br /><center>Number of Tickets: ".$num."</center>";
echo 
"<br /><div align='center' id='question'><strong>".ucfirst($user)."<br /></strong>".$message."<br /></div>";
// Find Their Email Address

$emailsql "SELECT email FROM users WHERE username='$username'";
$emailresult mysql_query($emailsql);
$erow mysql_fetch_assoc($emailresult);

$email $erow['email'];


if (
$submit){

$answer $_POST['answer'];

$signature "If you have anymore questions, feel free to ask! \nThank You,\n<html><a href='http://www.daobux.com'>Daobux Team</a></html>";
$usermail ucfirst($username);
mail("$email""Reply: $message""
Hello 
$usermail,\n
$answer\n
$signature
"
);

$answeredsql "UPDATE `support` SET `answered`='yes' WHERE number='$number'";
mysql_query($answeredsql);



}


}

?>

<html>
<head>
<title>Support Tickets</title>
<style>
#question{
    width: 500px;
    background-color: #cccccc;
    border-style: solid;
    border-width: 2px;
    margin-left: auto;
    margin-right: auto;
    }
</style>
</head>
<body OnLoad="document.supportticket.answer.focus();">

<center>
<h1>Answer Queries:</h1>
<form name="supportticket" action="supportticket.php" method="POST">
<textarea rows="8" cols="50" name="answer"></textarea><br />
<input type="submit" name="submit" value="Submit">
</form>
<br />
<?php echo $error?>
</center>

</body>
</html>
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-13-2010, 09:38 PM Re: Refresh information on submit
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You should move your submit processing logic before the script pulls a new list of rows, because the previous ticket is still set to answered=no
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 07-13-2010, 09:41 PM Re: Refresh information on submit
Skilled Talker

Posts: 83
Trades: 0
Once I do this, I have unset variables, and it causes all sorts of problems.
Smudly is offline
Reply With Quote
View Public Profile
 
Old 07-13-2010, 09:49 PM Re: Refresh information on submit
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You might have better luck seperating the processing logic from the presentation logic, because your processing is changing what the presentation is displaying. They may require you to access the db twice - once to update the data and the other to display it.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Refresh information on submit
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28765 seconds with 12 queries