Jump to content

Recommended Posts

Has anyone got an idea as to what I'm doing wrong, and how I can get it to work?

 

 

 $content = "<form action='a.php' method='post'><table border=1>";
      $content .= "<tr><td>Name Surname</td><td>Pet Name</td><td>Case Complaint</td><td>Payment Type</td><td>Payment Status</td><td>Responded</td><td>View</td><td> </td></tr>";
      for ($i=0;$i<count($cases);$i++)
      {
        if (!(has_responses($cases[$i]['case_id'])) && ($archive==false))
        {
          $user = user_details($cases[$i]['userid']);
          $pet = user_pet_details($cases[$i]['pets_id']);

          $content .= "<tr><td>".$user['name'] ." ".$user['surname']."</td><td>".$pet['pets_name']."</td><td>".$cases[$i]['case_complaint']."</td><td>".$cases[$i]['payment_type']."</td><td><input type='hidden' name='payment_status' value=".$cases[$i]['payment_status'].">".$cases[$i]['payment_status']."</td><td>".$cases[$i]['responded']."</td><td><a href=cases.php?id=".$cases[$i]['case_id'].">View</td><td><input name='move[]' type='checkbox' value=".$cases[$i]['case_id']."></td></tr>";
        }
        else if (($archive) && (has_responses($cases[$i]['case_id'])))
        {
          $user = user_details($cases[$i]['userid']);
          $pet = user_pet_details($cases[$i]['pets_id']);

          $content .= "<tr><td>".$user['name'] ." ".$user['surname']."</td><td>".$pet['pets_name']."</td><td>".$cases[$i]['case_complaint']."</td><td>".$cases[$i]['payment_type']."</td><td><input type='hidden' name='payment_status' value=".$cases[$i]['payment_status'].">".$cases[$i]['payment_status']."</td><td>".$cases[$i]['responded']."</td><td><a href=cases.php?id=".$cases[$i]['case_id'].">View</td><td><input name='move[]' type='checkbox' value=".$cases[$i]['case_id']."></td></tr>";
        }
      }
      $content .= "<tr><td><input type='submit' value='submit'></td></tr></table><form>";

 

 

 

<?php
mysql_connect("localhost", "root", "") or die ("Could not connect");
mysql_select_db("dbase") or die ("Could not connect to DB");


if ($_POST['move'])

{
foreach($_POST["move"] as $key => $id)
{
$tt = $_POST['payment_status'];

if($tt == "NOT PAID"){
$sql1=mysql_query("select * FROM `case` WHERE `case_id` = '".(int)$id."' limit 0,1") or die(mysql_error());
$sql=mysql_query("update `case` SET `payment_status` = 'PAID' WHERE `case_id` like '".(int)$id."'") or die(mysql_error());
}
ELSE if($tt == "PAID"){
$sql1=mysql_query("select * FROM `case` WHERE `case_id` = '".(int)$id."' limit 0,1") or die(mysql_error());
$sql=mysql_query("update `case` SET `payment_status` = 'NOT PAID' WHERE `case_id` like '".(int)$id."'") or die(mysql_error());
}
}
}

else
{
echo "please select at least one row, to delete it";
}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/172792-postingif-statement/
Share on other sites

Can anyone see what I'm doing wrong to pass the variable?

 

form

$content = "<form action='a.php' method='post'><table border=1>";
      $content .= "<tr><td>Name Surname</td><td>Pet Name</td><td>Case Complaint</td><td>Payment Type</td><td>Payment Status</td><td>Responded</td><td>View</td><td> </td></tr>";
      for ($i=0;$i<count($cases);$i++)
      {
        if (!(has_responses($cases[$i]['case_id'])) && ($archive==false))
        {
          $user = user_details($cases[$i]['userid']);
          $pet = user_pet_details($cases[$i]['pets_id']);

          $content .= "<tr><td>".$user['name'] ." ".$user['surname']."</td><td>".$pet['pets_name']."</td><td>".$cases[$i]['case_complaint']."</td><td>".$cases[$i]['payment_type']."</td><td><input type='hidden' name='payment_status' value=".$cases[$i]['payment_status'].">".$cases[$i]['payment_status']."</td><td>".$cases[$i]['responded']."</td><td><a href=cases.php?id=".$cases[$i]['case_id'].">View</td><td><input name='move[]' type='checkbox' value=".$cases[$i]['case_id']."></td></tr>";
        }
        else if (($archive) && (has_responses($cases[$i]['case_id'])))
        {
          $user = user_details($cases[$i]['userid']);
          $pet = user_pet_details($cases[$i]['pets_id']);

          $content .= "<tr><td>".$user['name'] ." ".$user['surname']."</td><td>".$pet['pets_name']."</td><td>".$cases[$i]['case_complaint']."</td><td>".$cases[$i]['payment_type']."</td><td><input type='hidden' name='payment_status' value=".$cases[$i]['payment_status'].">".$cases[$i]['payment_status']."</td><td>".$cases[$i]['responded']."</td><td><a href=cases.php?id=".$cases[$i]['case_id'].">View</td><td><input name='move[]' type='checkbox' value=".$cases[$i]['case_id']."></td></tr>";
        }
      }
      $content .= "<tr><td><input type='submit' value='submit'></td></tr></table><form>";

 

Request

<?php
mysql_connect("localhost", "root", "") or die ("Could not connect");
mysql_select_db("cyberndt_cybervet") or die ("Could not connect to DB");


if ($_POST['move'])

{$tt = $_POST['payment_status'];
foreach($_POST['move'] as $key => $id)
{

if($tt == "NOT PAID"){
$sql1=mysql_query("select * FROM 'case' WHERE 'case_id' = '".(int)$id."' limit 0,1") or die(mysql_error());
$sql=mysql_query("update 'case' SET 'payment_status' = 'PAID' WHERE 'case_id' like '".(int)$id."'") or die(mysql_error());
echo "not paid value changed to paid";
}
ELSE if($tt == "PAID"){
$sql1=mysql_query("select * FROM 'case' WHERE 'case_id' = '".(int)$id."' limit 0,1") or die(mysql_error());
$sql=mysql_query("update 'case' SET 'payment_status' = 'NOT PAID' WHERE 'case_id' like '".(int)$id."'") or die(mysql_error());
echo "paid value changed to not paid";
}
else
{
echo "please select at least one row, to delete it";
}}
}


?>

Link to comment
https://forums.phpfreaks.com/topic/172792-postingif-statement/#findComment-913970
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.