Jump to content

[SOLVED] How do I change the enum value based on user clicking


jeff5656

Recommended Posts

I have a variable called completed with enum of either  'y' or 'n'.

When a user clicks this link

 

<a href="updatebill.php?action=edit&id=<?php
 echo $row2['dos_id']; ?>">		

		<?php echo $row2['completed'];?></a>

 

I want to change the value to n if it is set as y, and y if it is set as n.

 

Here is the action php file that the link goes to:

switch ($_GET['action']) {
case "edit":

$sql = "UPDATE dos SET completed = 'n'";


if (isset($sql) && !empty($sql)) {
echo "<!--" . $sql . "-->";
$result = mysql_query($sql) or die ("Invalid query: " . mysql_error());

}

So everytime they click it, the value changes from it's current value (either y or n) to the Other value.

 

Thanks!

If you pass the character in the url;

 

<a href="updatebill.php?action=edit&id=<?php
    echo $row2['dos_id'].'&completed='.$row2['completed']; ?>">      
         
         <?php echo $row2['completed'];?></a>

 

Then on the next page set the variable to use in the sql query;

 

$completed = ($_GET['completed'] == 'y')? 'n' : 'y';

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.