jay7981 Posted November 27, 2009 Share Posted November 27, 2009 I have a table that is populated with mysql data and in teh first column there is a raido button that i would like to have it when selected and i hit either edit or delete the ID is passed to another page for the stated task. i am using raidos to prevent multiple selections. but at this time when switching selections all previous ones stay until a refresh. how can i fix this ? Please help i am at a complete loss..... Here is the code:: <?php require_once('../Connections/BIO_Clan.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_BIO_Clan, $BIO_Clan); $query_Leaders = "SELECT clan_members.authid, clan_members.rank, clan_members.name, admins.access FROM imagest5_bioclan.clan_members LEFT OUTER JOIN imagest5_bioclan.admins ON clan_members.name = admins.name WHERE clan_members.rank = 6 ORDER BY clan_members.rank DESC, clan_members.name"; $Leaders = mysql_query($query_Leaders, $BIO_Clan) or die(mysql_error()); $row_Leaders = mysql_fetch_assoc($Leaders); $totalRows_Leaders = mysql_num_rows($Leaders); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="100%" border="1" cellpadding="2" cellspacing="2"> <tr> <td> </td> <td>SteamID</td> <td>Name</td> <td>Flags</td> </tr> <?php do { ?> <tr> <td><form id="form4" name="form4" method="post" action=""> <input type="radio" name="select" id="radio" value="<?php echo $row_Leaders['authid']; ?>" /> </form></td> <td><?php echo $row_Leaders['authid']; ?></td> <td><?php echo $row_Leaders['name']; ?></td> <td><?php echo $row_Leaders['access']; ?></td> </tr> <?php } while ($row_Leaders = mysql_fetch_assoc($Leaders)); ?> </table> <div align="center"><br /> <table width="62%"> <tr> <td width="11%"><form id="form1" name="form1" method="post" action="edit.php"> <div align="center"> <input type="submit" name="edit" id="edit" value="Edit" /> </div> </form></td> <td width="20%"><form id="form2" name="form2" method="post" action="delete.php"> <div align="center"> <input type="submit" name="delete" id="delete" value="Delete" /> </div> </form></td> <td width="69%"><form id="form3" name="form3" method="post" action=""> <div align="center"> <select name="admin" id="select"> <option selected="selected">Quick Admin----</option> <option>Ldr/CoLdr</option> <option>Tech</option> <option>Upper Admin</option> <option>Mid Admin</option> <option>Recruit Admin</option> <option value="u">Member</option> </select> <input type="submit" name="admin" id="admin" value="Set" /> </div> </form></td> </tr> </table> </div> </body> </html> <?php mysql_free_result($Leaders); ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/ Share on other sites More sharing options...
dgoosens Posted November 27, 2009 Share Posted November 27, 2009 all the radio buttons should be part of the same form... thus you should move this line <form id="form4" name="form4" method="post" action=""> and this line </form> out of your loop Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-966416 Share on other sites More sharing options...
jay7981 Posted November 27, 2009 Author Share Posted November 27, 2009 how am i going pull the loop when there are multiple forms ? ive never really been good with form building. the idea is that when you select a record and hit edit you goto edit.php and if you select a record and hit delete it takes you to delete.php and also when you select a record and select an option from the dropdown and hit set it takes you to add_x.php Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-966513 Share on other sites More sharing options...
kratsg Posted November 27, 2009 Share Posted November 27, 2009 how am i going pull the loop when there are multiple forms ? ive never really been good with form building. the idea is that when you select a record and hit edit you goto edit.php and if you select a record and hit delete it takes you to delete.php and also when you select a record and select an option from the dropdown and hit set it takes you to add_x.php He means that if all the radios are in one form, then depending on what button you click, you'll process the form data and send the user to where/what they want. Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-966539 Share on other sites More sharing options...
eugene2009 Posted November 27, 2009 Share Posted November 27, 2009 use a drop down list Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-966543 Share on other sites More sharing options...
jay7981 Posted November 27, 2009 Author Share Posted November 27, 2009 ok here is what i have done, i have changed it to 1 single form with multiple submit buttons, now i am trying to figure out how to write the switch/case functions to handle the passed on information. As i am extreamly new to using switch and case here is what i have so far.. any help with this would be GREAT and thank you all for any help. If it helps i am using Dreamweaver CS4 and utilizing the dataset feature to build the table inside of a spry tabbed panel. the table is working flawlessly as is the spry tabbed panels. here is a step by step of what i am trying to accomplish. A user logs into a page (main.php) and sees the tabbed panels with the tabels and buttons. when a record is selected they can: click on edit and recieve a form that has the current values that are in the mysql table ($members_table) already populated in text field that they can change and then hit update and it updates the record in the mysql table ($members_table). click on delete and delete the record from mysql table ($members_table). add the ID and name to a different mysql table ($admin_table) with the pre defined values of the Quick Add dropdown or update the "access" in the same table if the ID is already there. I know i am on the right track of accomplishing this HOWEVER i am stuck on the edit.inc, delete.inc and mem2admin1.inc and how to shift the info that was passed to the process.php to the included edit.inc, delete.inc and mem2admin1.inc forms. The Table/Form: <?php require_once('../Connections/BIO_Clan.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_BIO_Clan, $BIO_Clan); $query_Leaders = "SELECT clan_members.authid, clan_members.rank, clan_members.name, admins.access FROM imagest5_bioclan.clan_members LEFT OUTER JOIN imagest5_bioclan.admins ON clan_members.name = admins.name WHERE clan_members.rank = 9 ORDER BY clan_members.rank DESC, clan_members.name"; $Leaders = mysql_query($query_Leaders, $BIO_Clan) or die(mysql_error()); $row_Leaders = mysql_fetch_assoc($Leaders); $totalRows_Leaders = mysql_num_rows($Leaders); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form method="post" action="./process.php"> <table width="100%" border="1" cellpadding="2" cellspacing="2"> <tr> <td> </td> <td>SteamID</td> <td>Name</td> <td>Flags</td> </tr> <?php do { ?> <tr> <td><input type="radio" name="select[]" id="radio" value="<?php echo $row_Leaders['authid']; ?>" /></td> <td><?php echo $row_Leaders['authid']; ?></td> <td><?php echo $row_Leaders['name']; ?></td> <td><?php echo $row_Leaders['access']; ?></td> </tr> <?php } while ($row_Leaders = mysql_fetch_assoc($Leaders)); ?> </table> <div align="center"><br /> <table width="62%"> <tr> <td width="11%"><div align="center"> <input type="submit" name="submit[edit]" value="Edit"> </div></td> <td width="20%"><div align="center"> <input type="submit" name="submit[delete]" value="Delete"> </div></td> <td width="69%"><div align="center"> <select name="set" id="set"> <option selected="selected">Quick Admin----</option> <option>Ldr/CoLdr</option> <option>Tech</option> <option>Upper Admin</option> <option>Mid Admin</option> <option>Recruit Admin</option> <option value="u">Member</option> </select> <input type="submit" name="submit[set]" value="Set"> </div></td> </tr> </table> </div> </form> </body> </html> <?php mysql_free_result($Leaders); ?> The Processor: <?php // uncomment for debug print_r($_POST); // check that form has been posted if ($_POST) { switch ($action) { case 'edit': // show appropriate forms echo include('./includes/edit.inc'); break; case 'delete': echo include('./includes/delete.inc'); break; case 'set': echo include('./includes/mem2admin1.inc'); break; } } ?> The included Edit.inc: <?php //The connection details include 'config.php'; //defines of $rank and $access include 'access.php'; if(!isset($_SESSION['clan_id'])) { die("You are not logged in and cannot view this page."); } //include 'modeheader.php'; $db = mysql_connect ($hostname, $username, $password) or die ('Failed to connect to database: ' . mysql_error()); mysql_select_db ($database); $query = "SELECT * FROM $member_table WHERE authid='" . $_POST['auth'] . "'"; $result = mysql_query($query) or die ("Cannot query table " . mysql_error()); $row = mysql_fetch_assoc($result); $auth = $row['authid']; $rank = $row['rank']; $name = $row['name']; mysql_free_result($result); mysql_close($db); echo "<form action=\"member_update.php\" method=\"post\">"; echo "SteamID: <input name=\"auth\" type=\"text\" value=\"$auth\"><br>"; echo "Name: <input name=\"name\" type=\"text\" value=\"$name\"><br>"; echo "Rank:<br>"; //echo "Rank: <input name\"rank\" type=\"text\" value=\"$rank\"><br>"; $size = sizeof($ranks) - 1; echo "<p>"; for($count = $size;$count > 0;$count--) { echo "<label>"; echo "<input type=\"radio\" name=\"rank\" value=\"$count\""; if($rank == $count) { echo " checked"; } echo ">$ranks[$count]</label><br>"; } echo "<br><input type=\"submit\" value=\"Update Member\"><br></form>"; ?> The delete.inc <?php if(!isset($_SESSION['clan_id'])) { die("You are not logged in and cannot view this page."); } echo "<center>"; echo "Are you sure you want to delete:<br><br>"; $auth = $_REQUEST['auth']; echo "<font color=\"#FF0000\" size=\"4\">$auth</font>"; echo "<br><br><a href=\"deleteconfirmed.php?auth=$auth\">Yes</a> <a href=\"main.php\">No</a></center>"; ?> The mem2admin1.inc <?php if(!isset($_SESSION['clan_id'])) { die("You are not logged in and cannot view this page."); } echo '<center>'; $auth = $_REQUEST['auth']; $name = $_REQUEST['name']; $access = $_REQUEST['access']; echo "<br><br>Are you sure you want to give '$access' flags to:<br><br>"; echo "SteamID: $auth<br />Name: $name"; echo "<br><br><a href=\"admin_add3.php?auth=$auth&name=$name&access=$access\">Yes</a> <a href=\"main.php\">No</a></center>;" ?> Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-966558 Share on other sites More sharing options...
jay7981 Posted November 28, 2009 Author Share Posted November 28, 2009 any suggestions? Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-966975 Share on other sites More sharing options...
jay7981 Posted November 29, 2009 Author Share Posted November 29, 2009 Please close i resolved this myself. Thanks. Link to comment https://forums.phpfreaks.com/topic/183110-dynamic-table-with-forms/#findComment-967264 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.