kemper Posted March 2, 2008 Share Posted March 2, 2008 I run a youth sports website and write their schedules. I have a php script that I implimented that allows club field schedulers to add times into games at their fields. Currently, it allows editting of each record (game) individually. I would like to make it easier for those schedulers to enter times into all games in one simple form process. I am wondering how to change it so that all records can be displayed and edited on one page, in one submission (like the attached image). My current scheduling.php file is: <?php require_once "../maincore.php"; require_once "../subheader.php"; require_once "../side_left.php"; include LOCALE.LOCALESET."sched.php"; //if (!checkrights("FS")) fallback("../index.php"); if (isset($_POST['edit_sched'])) { $time = stripinput($_POST['time']); $time_text = stripinput($_POST['time_text']); $game_time = stripinput($_POST['game_time']); $home_field = stripinput($_POST['field']); $field_no = stripinput($_POST['field_no']); $result = dbquery("UPDATE scheduless SET sched_user='".$userdata['user_id']."', time_text='$time_text', game_time='$game_time', field='$field', field_no='$field_no' WHERE game_id='$game_id' "); //$result = dbquery("UPDATE ".$db_prefix."faq_cats SET faq_cat_name='$faq_cat_name' WHERE faq_cat_id='$faq_cat_id'"); } if ($step == "edit"){ //$data = dbarray(dbquery( // "SELECT ter.*, user_id,user_name FROM scheduless ter // LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id // WHERE game_id='$game_id'" // )); $data = dbarray(dbquery("SELECT * FROM schedules WHERE game_id='$game_id'")); // note change here $display_time = date("g:i a", strtotime($data['time'])); opentable ($locale['sched001']); echo "<form name='reportform' method='post' action='".FUSION_SELF."?game_id=$game_id'> ".$locale['sched120']." <table align='center' cellspacing='5' cellpadding='5' class='tbl' width='375'> <tr> <td valign='top' width='124'> <p style='margin-top: 0; margin-bottom: 0'><b>Division:</b></td> <td valign='top' width='216'> <p style='margin-top: 0; margin-bottom: 0'>".$data['s08div']."</p> </td> </tr> <tr> <td width='124' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><b>Game ID:</b></td> <td width='216' valign='top'> <p style='margin-top: 0; margin-bottom: 0'>".$data['game_id']."</td> </tr> <tr> <td width='124' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><b>Date:</b></td> <td width=216' valign='top'> <p style='margin-top: 0; margin-bottom: 0'>".$data['game_date']=date("D, M j, Y",strtotime($data['game_date']))."</td> </tr> <tr> <td width='124' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><b>Time/Notes:</b></td> <td width='216' valign='top'> <p style='margin-top: 0; margin-bottom: 0'> <span style='background-color: #FFFF00'>".$data['notes']."</span></td> </tr> ".(checkrights("A") ? "<tr> <td valign='top' width='124' bgcolor='#C0C0C0'> <p style='margin-top: 0; margin-bottom: 0'><b>Official Time:</b></td> <td valign='top' width='216' bgcolor='#C0C0C0'> <p style='margin-top: 0; margin-bottom: 0'><input type='text' name='game_time' value='".$data['game_time']."' class='textbox' style='width:75px;'></td> </tr>" : "")." <tr> <td valign='top' width='124'> <p style='margin-top: 0; margin-bottom: 0'><b>Time</b></td> <td valign='top' width='216'> <p style='margin-top: 0; margin-bottom: 0'><input type='text' name='time_text' value='".$data['time_text']."' class='textbox' style='width:75px;'></td> </tr> <tr> <td width='124' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><b>Match-up:</b></td> <td width='216' valign='top'> <p style='margin-top: 0; margin-bottom: 0'>".$data['home_team']."</p> <p style='margin-top: 0; margin-bottom: 0'><font color='#0000FF'>vs.</font> ".$data['visit_team']."</td> </tr> <tr> <td width='124' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><b>Field:</b></td> <td width='216' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><input type='text' name='field' value='".$data['field']."' class='textbox' style='width:150px;'></td> </tr> <tr> <td width='124' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><b>Field # or Name:</b></td> <td width='216' valign='top'> <p style='margin-top: 0; margin-bottom: 0'><input type='text' name='field_no' value='".$data['field_no']."' class='textbox' style='width:100px;'></td> </tr> <tr> <td align='center' colspan='2'> <input type='submit' name='edit_sched' value='".$locale['sched135']."' class='button'></td> </tr> </table> </form>\n"; closetable (); } opentable ($locale['sched001']); $sql = dbquery( "SELECT ter.*, user_id,user_name FROM schedules ter LEFT JOIN ".$db_prefix."users tusr ON ter.sched_user=tusr.user_id ORDER BY game_date ASC,game_time ASC" ); // note change here $display_time = date("g:i a", strtotime($data['time'])); if (dbrows($sql)) { $i = 0; echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'> <tr> <td colspan='9' bgcolor='#FFFF00'> <p style='margin-top: 0; margin-bottom: 0'><font size='2'>Below is a list of games scheduled at your club/district's home fields. To add Times and Field Specifics, click "<font color='#FF0000'>Edit</font>" next to the corresponding game.</td></tr> <tr> <td><b><font size='1'>Division:</font></b></td> <td><b><font size='1'>Game ID:</font></b></td> <td><b><font size='1'>Date:</font></b></td> <td><b><font size='1'>Time/Notes:</font></b></td> <td><b><font size='1'>Time:</font></b></td> ".(checkrights("A") ? "<td><b><font size='1'>Off. Time:</font></b></td>" : "")." <td><b><font size='1'>Teams:</font></b></td> <td><b><font size='1'>Field:</font></b></td> <td><b><font size='1'>Options:</font></b></td> </tr>\n"; while ($data = dbarray($sql)) { $i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2"; if ($data['game_date'] != $prev) { // if division changed echo "<tr><td colspan='3'> </td></tr>\n"; // blank row $prev = $data['game_date']; } echo "<tr> <td class='$tclass'><font size='1'>".$data['s08div']."</font></td> <td class='$tclass'><font size='1'>".$data['game_id']."</font></td> <td class='$tclass'><font size='1'>".$data['game_date']=date("D, M j, Y",strtotime($data['game_date']))."</font></td> <td class='$tclass'><font size='1'><span style='background-color: #FFFF00'>".$data['notes']."</span></font></td> <td class='$tclass'><font color='#0000FF' size='1'>".$data['time_text']."</font></td> ".(checkrights("A") ? "<td class='$tclass'><font color='#0000FF' size='1'>".$data['game_time']."</font></td>" : "")." <td class='$tclass'> <p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$data['home_team']." vs.</font></p> <p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$data['visit_team']."</font></font></td> <td class='$tclass'><font color='#0000FF' size='1'>".$data['field']." ".$data['field_no']."</font></td> <td class='$tclass'><center><a href='".FUSION_SELF."?step=edit&game_id=".$data['game_id']."'> <font size='1'>".$locale['sched002']."</font></a></center></td> </tr>\n"; } echo "</table>\n"; } else { echo "<center><br>\n".$locale['sched141']."<br><br>\n</center>\n"; } closetable(); echo "</td>\n"; require_once BASEDIR."footer.php"; ?> Any suggestions? Link to comment https://forums.phpfreaks.com/topic/93945-edit-multiple-db-records/ Share on other sites More sharing options...
trq Posted March 2, 2008 Share Posted March 2, 2008 What part exactly are you stuck with? Link to comment https://forums.phpfreaks.com/topic/93945-edit-multiple-db-records/#findComment-481340 Share on other sites More sharing options...
kemper Posted March 2, 2008 Author Share Posted March 2, 2008 The current script works fine, but I would like to make it more user friendly and less tedious. I am stuck at the <form>, changing from single entry to multiple entries. I want it to list all records with <inputs> for time field all in one table. The Submit would update all records. Link to comment https://forums.phpfreaks.com/topic/93945-edit-multiple-db-records/#findComment-481348 Share on other sites More sharing options...
kemper Posted March 2, 2008 Author Share Posted March 2, 2008 I thought I might by in the right direction with: <form name='reportform' method='post' action='".FUSION_SELF."> <table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'> <tr> <td colspan='8' bgcolor='#FFFF00'> <p style='margin-top: 0; margin-bottom: 0'><font size='2'>Below is a list of games scheduled at your club/district's home fields. To add Times and Field Specifics, click "<font color='#FF0000'>Edit</font>" next to the corresponding game. </td></tr> <tr> <td><b><font size='1'>Division:</font></b></td> <td><b><font size='1'>Game ID:</font></b></td> <td><b><font size='1'>Date:</font></b></td> <td><b><font size='1'>Time/Notes:</font></b></td> <td><b><font size='1'>Time:</font></b></td> ".(checkrights("A") ? "<td><b><font size='1'>Off. Time:</font></b></td>" : "")." <td><b><font size='1'>Teams:</font></b></td> <td><b><font size='1'>Field:</font></b></td> </tr>\n"; while ($data = dbarray($sql)) { $i % 2 == 0 ? $tclass="tbl1" : $tclass="tbl2"; if ($data['game_date'] != $prev) { // if division changed echo "<tr><td colspan='3'> </td></tr>\n"; // blank row $prev = $data['game_date']; } echo "<tr> <td class='$tclass'><font size='1'>".$data['s08div']."</font></td> <td class='$tclass'><font size='1'>".$data['game_id']."</font></td> <td class='$tclass'><font size='1'>".$data['game_date']=date("D, M j, Y",strtotime($data['game_date']))."</font></td> <td class='$tclass'><font size='1'><span style='background-color: #FFFF00'>".$data['notes']."</span></font></td> <td class='$tclass'><font color='#0000FF' size='1'><input type='text' name='time_text' value='".$data['time_text']."' class='textbox' style='width:75px;'></font></td> ".(checkrights("A") ? "<td class='$tclass'><font color='#0000FF' size='1'><input type='text' name='game_time' value='".$data['game_time']."' class='textbox' style='width:75px;'></font></td>" : "")." <td class='$tclass'> <p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$data['home_team']." vs.</font></p> <p style='margin-top: 0; margin-bottom: 0'><font size='1'>".$data['visit_team']."</font></font></td> <td class='$tclass'><font color='#0000FF' size='1'><input type='text' name='field' value='".$data['field']."' class='textbox' style='width:150px;'> <input type='text' name='field_no' value='".$data['field_no']."' class='textbox' style='width:100px;'></font></td> </tr>\n"; } echo "<tr> <td align='center' colspan='8'> <input type='submit' name='edit_sched' value='".$locale['sched135']."' class='button'></td> </tr> </table> </form> But, I did not even get the records to display. Assistance is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/93945-edit-multiple-db-records/#findComment-481373 Share on other sites More sharing options...
kemper Posted March 2, 2008 Author Share Posted March 2, 2008 anyone? Link to comment https://forums.phpfreaks.com/topic/93945-edit-multiple-db-records/#findComment-481616 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.