Dropdowns not posting MySQL Update?

I am trying to create an update status feature. The sitename goes in one field, and the status goes in the other. I’ve been able to do it before, but this time I decided to have the sitename come up in a dropdown menu generated through php and a mysqlquery. Here’s the code for the form:

[php]
function PendingLinks(){
global $database;
$q = "SELECT status,name "
.“FROM “.TBL_LINK_EXCHANGE.” WHERE status=‘Pending’ ORDER BY name”;
$result = $database->query($q);
/* Error occurred, return given name by default /
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
echo “Error displaying info”;
return;
}
if($num_rows == 0){
echo “Database table empty”;
return;
}
/
Display table contents */
echo “”;
for($i=0; $i<$num_rows; $i++){
$status = mysql_result($result,$i,“status”);
$webname = mysql_result($result,$i,“name”);
echo “$webname”; }
echo “”;
}

?>

Approve/Reject Item


<?php echo “”;
PendingLinks();
echo “ApprovedRejected”;
echo " ";
echo “”; ?>

[/php]

I’ve created a process.php, however code that I’ve used before doesn’t seem to work the same when there’s a generated dropdown. I’m trying to get it so that the person can choose the website from a dropdown, then choose whether to approve or reject from the next dropdown, and once submitted, it updates the database. Here’s my code as of right now:

[php]<?php
/* link_exchange_process.php
This file will do the processing for the Link Exchange Manager page. */
include(“session.php”);

class Link_Exchange_Process
{
//Class constructor
function ApproveReject(){
global $session;
//* Make sure administrator is accessing page
if(!$session->isAdmin()){
header(“Location: main.php”);
return;
}
//* Admin submitted Approve/Reject form
if(isset($_POST[‘subupdstatus’])){
$this->procApproval();
}

} //bracket for function approvereject

/*Process for Approval or Rejection of Websites */
function procApproval(){
$webname = $_POST[‘name’];
$status = $_POST[‘status’];
$database->updateUserField($webname, “status”, $status);

} //bracket from procApproval

} //bracket for class
?>[/php]

As usual, thank you in advance for your assistance. As of right now, it doesn’t bring up any error messages, there is just no update.

I was not calling the function at the end. I’m hoping that in the future, I can put other functions in the same file and call them using the isset function as I’m doing for this one. I obviously don’t quite understand classes, so I’ve taken them out until I can learn more about them.

Form Code:
[php] function PendingLinks(){
global $database;
$q = "SELECT status,name "
.“FROM “.TBL_LINK_EXCHANGE.” WHERE status=‘Pending’ ORDER BY name”;
$result = $database->query($q);
/* Error occurred, return given name by default /
$num_rows = mysql_numrows($result);
if(!$result || ($num_rows < 0)){
echo “Error displaying info”;
return;
}
if($num_rows == 0){
echo “Database table empty”;
return;
}
/
Display pending sites at dropdown options */

for($i=0; $i<$num_rows; $i++){
$status = mysql_result($result,$i,“status”);
$webname = mysql_result($result,$i,“name”);
echo “$webname”; }
}

?>

Approve/Reject Item





Choose a site
<?php PendingLinks(); ?>


Approved
Rejected




[/php]

Process Code:
[php]/*Process for Approval or Rejection of Websites */
function procApproval(){
global $session, $database, $form;
$name = $_POST[‘name’];
$status = $_POST[‘status’];
$q = (“UPDATE link_exchange SET status=’”.$_POST[‘status’]."’ WHERE name=’$name’ ");
$database -> query($q);
} //bracket from procApproval

  //* Admin submitted Approve/Reject form 
  if(isset($_POST['subupdstatus'])){
     procApproval();
  }

[/php]

I had the same problem yesterday

i solved it by changing

to

seemed strange to me at the time but it seems to have worked

I will give this a try! Thank you!

Sponsor our Newsletter | Privacy Policy | Terms of Service