CMellor Posted April 25, 2006 Share Posted April 25, 2006 First, I'd like to show my code:[code]<form action="" method="post"> <table width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="30%" align="center" class="header">Team Name</td> <td width="40%" align="center" class="header">Members</td> <td width="20$" align="center" class="header">Accept</td> <td width="10%" align="center" class="header">Delete</td> </tr> <?php $query = mysql_query("SELECT * FROM $dbname.request_stable"); while($row = mysql_fetch_array($query)) { if($_GET['accept'] == "true") { mysql_query("UPDATE $dbname.request_stable SET accepted = 'yes' WHERE id = ".$_POST['id'].""); } ?> <tr> <td class="row2"><?=$row['group_name']?></td> <td class="row2"><strong><?=$row['leader']?></strong><br /><?=$row['members']?></td> <td align="center" class="row2"><input type="hidden" name="id" value="<?=$row['id']?>" /> <?php if($row['accepted'] == "no") { ?>Not Appepted<br /> [ <a href="?do=interactive_requests_stable&accept=true">Accept</a> ] <?php } else { ?>Accepted<?php } ?> </td> <td align="center" class="row2"><input type="checkbox" name="delete[]" value="<?=$row['id']?>" /></td> </tr> <?php } ?> </table> <div align="right"> <input type="submit" name="delete_stable" value="Delete Selected" class="button" /></div> </form>[/code]That produces a table that grabs some details from the DB. In the DB, their is a table called 'accepted' and can have the value of 'yes' or 'no'. When set to 'no', it says [b]Not Accepted [ Accept ][/b] and when set to 'yes' it says [b]Accepted[/b].I want it so when you click [b][ Accept ][/b], it updates the DB status to 'yes' from 'no'. I thought putting a hidden input with the row id as the value, then using $_POST['id'] in the mysql query might get it to set the selected row to update, but nothing happens when I click it.Hope I make sense, I never seem to think I do when I ask for help here.Thanks for taking the time to look and I hope to hear from you soon.Chris. Quote Link to comment https://forums.phpfreaks.com/topic/8378-having-trouble-using-_post/ Share on other sites More sharing options...
wildteen88 Posted April 25, 2006 Share Posted April 25, 2006 The reason why it aint working is becuase you are using a link and so the form isn't being submitted and so no $_POST array is created. What you will want to is put id into the link like so:[code]<a href="?do=interactive_requests_stable&accept=true&id=<?=$row['id']?>">Accept</a>[/code]Then change $_POSt['id'] in your SQL Quuery to $_GET['id'] so you SQL Query will be like so:[code]mysql_query("UPDATE $dbname.request_stable SET accepted = 'yes' WHERE id = ".$_GET['id']."");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8378-having-trouble-using-_post/#findComment-30635 Share on other sites More sharing options...
CMellor Posted April 25, 2006 Author Share Posted April 25, 2006 Cheers bud. Believe it or not, I actually figured it out after I posted this, lol, but I did it pretty much the way you suggested.Thanks again.Chris. Quote Link to comment https://forums.phpfreaks.com/topic/8378-having-trouble-using-_post/#findComment-30648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.