OK I have a slight problem that I think can be easily fixed... The code I am about to display is supposed to display a table filled with lead information, which it does just fine. Each lead has a select box to change the status of the lead in the db. HEREIN LIES THE PROBLEM. I do not know how to tell my sql query which lead to update... The leadID is supposed to be the lead to change but I dont know how to tell my sql that the action being taken is supposed to be done to this specific lead... Here is the code:
Help with a simple php problem
11
OK I have a slight problem that I think can be easily fixed...
The code I am about to display is supposed to display a table filled with lead information, which it does just fine. Each lead has a select box to change the status of the lead in the db. HEREIN LIES THE PROBLEM.
I do not know how to tell my sql query which lead to update... The leadID is supposed to be the lead to change but I dont know how to tell my sql that the action being taken is supposed to be done to this specific lead... Here is the code:
<?
function ticket_connect() {
$db_host = "localhost";
$db_user = "notgonnashowuthis";
$db_password ="notgonnashowuthis";
$db_name = "notgonnashowuthis";
//create database connection
$connection = @mysql_connect($db_host,$db_user,$db_password);
//if there is no connection then display a message letting the user know.
if($connection) {
@mysql_select_db($db_name, $connection);
}
else{
echo "ERROR!! Could not connect to the database at this time, we are sorry for the inconvenience. Please try again later.";
}
} // end function db_connect()
function changestatus($leadID,$status) {
ticket_connect();
$sql = mysql_query('UPDATE mynewci_ticket SET lead_status="$newstatus" WHERE ticketID="$lead2change"') or die(mysql_error());
}
$selstatus = "<select onchange='changestatus()'><option value='Renter Keep'>Renter Keep<option value='Renter Reject'>Renter Reject<option value='SPAM'>SPAM<option value='Sold Buyer'>Sold Buyer<option value='Sold Seller'>Sold Seller<option value='Not Moving'>Not Moving<option value='Listed Home'>Listed Home";
?>
<body>
<?
if(!$agentemail) {
?>
<script type="text/javascript">
window.location="notgonnashowuthis";
</script>
<?
}
ticket_connect();
$result = mysql_query("SELECT ticketID,created,lead_status,subject,lo_franchise, email,name,lead_email,lead_name FROM mynewci_ticket WHERE email='$agentemail'") or die(mysql_error());
echo "<table id='gettickettable' border='1'>";
echo "<form method='post' action='notgonnashowuthis'>";
echo "<th>Ticket Number</th><th>Capture Date</th><th>Status</th><th>Subject</th><th>Franchise</th><th>Lead Owner</th><th>Owner Name</th><th>Lead Email</th><th>Lead Name</th>";
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['ticketID'];
echo "</td><td>";
echo $row['created'];
echo "</td><td>";
echo $selstatus;
echo "</td><td>";
echo $row['subject'];
echo "</td><td>";
echo $row['lo_franchise'];
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['name'];
echo "</td><td>";
echo $row['lead_email'];
echo "</td><td>";
echo $row['lead_name'];
echo "</td></tr>";
}
echo "</table>";
?>
Keep in mind this code is not fully complete simply b/c i cannot make the SPECIFIC change so the changestatus function is not written as it will be.
I know it is a simple thing probably but I just dont know how to make it happen... Several thousand people are waiting on this and I am sweating bullets right now.... Please help if you can, it will be much appreciated
The code I am about to display is supposed to display a table filled with lead information, which it does just fine. Each lead has a select box to change the status of the lead in the db. HEREIN LIES THE PROBLEM.
I do not know how to tell my sql query which lead to update... The leadID is supposed to be the lead to change but I dont know how to tell my sql that the action being taken is supposed to be done to this specific lead... Here is the code:
<?
function ticket_connect() {
$db_host = "localhost";
$db_user = "notgonnashowuthis";
$db_password ="notgonnashowuthis";
$db_name = "notgonnashowuthis";
//create database connection
$connection = @mysql_connect($db_host,$db_user,$db_password);
//if there is no connection then display a message letting the user know.
if($connection) {
@mysql_select_db($db_name, $connection);
}
else{
echo "ERROR!! Could not connect to the database at this time, we are sorry for the inconvenience. Please try again later.";
}
} // end function db_connect()
function changestatus($leadID,$status) {
ticket_connect();
$sql = mysql_query('UPDATE mynewci_ticket SET lead_status="$newstatus" WHERE ticketID="$lead2change"') or die(mysql_error());
}
$selstatus = "<select onchange='changestatus()'><option value='Renter Keep'>Renter Keep<option value='Renter Reject'>Renter Reject<option value='SPAM'>SPAM<option value='Sold Buyer'>Sold Buyer<option value='Sold Seller'>Sold Seller<option value='Not Moving'>Not Moving<option value='Listed Home'>Listed Home";
?>
<body>
<?
if(!$agentemail) {
?>
<script type="text/javascript">
window.location="notgonnashowuthis";
</script>
<?
}
ticket_connect();
$result = mysql_query("SELECT ticketID,created,lead_status,subject,lo_franchise, email,name,lead_email,lead_name FROM mynewci_ticket WHERE email='$agentemail'") or die(mysql_error());
echo "<table id='gettickettable' border='1'>";
echo "<form method='post' action='notgonnashowuthis'>";
echo "<th>Ticket Number</th><th>Capture Date</th><th>Status</th><th>Subject</th><th>Franchise</th><th>Lead Owner</th><th>Owner Name</th><th>Lead Email</th><th>Lead Name</th>";
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['ticketID'];
echo "</td><td>";
echo $row['created'];
echo "</td><td>";
echo $selstatus;
echo "</td><td>";
echo $row['subject'];
echo "</td><td>";
echo $row['lo_franchise'];
echo "</td><td>";
echo $row['email'];
echo "</td><td>";
echo $row['name'];
echo "</td><td>";
echo $row['lead_email'];
echo "</td><td>";
echo $row['lead_name'];
echo "</td></tr>";
}
echo "</table>";
?>
Keep in mind this code is not fully complete simply b/c i cannot make the SPECIFIC change so the changestatus function is not written as it will be.
I know it is a simple thing probably but I just dont know how to make it happen... Several thousand people are waiting on this and I am sweating bullets right now.... Please help if you can, it will be much appreciated
- michael_gourlay
- [ 1 ] Thanks
- [2] replies
- PHPSpaZ
- PHPSpaZ
- [1] reply
- KirkMcD
- [ 1 ] Thanks
- [1] reply
- michael_gourlay
- [ 1 ] Thanks
- PHPSpaZ
- PHPSpaZ
- jassmee Banned
- ussher
Next Topics on Trending Feed
-
11