kemper Posted February 7, 2007 Share Posted February 7, 2007 I am hosting a youth sports website and am processing schedules for the particpating clubs to assign times and field assignments. Basically, I want a form to appear (if "Club 2" scheduler was logged in) similar to: Now, this is a screen-shot of my standard html form. I want to continue moving into the 21st Century and utilize database driven live updating. I am not sure where to start expect with database login information. Assistance is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/ Share on other sites More sharing options...
kemper Posted February 7, 2007 Author Share Posted February 7, 2007 I think that I must elaborate on what I want to do... I know how to display the data, but not to have the fill in fields for the two cells that my schedules will edit. I created that screenshot manually. How do I write the script to include edittable text fields under "Time" and "Field"? I was once told to add: Code: echo '<a href="editpage.php?id='.$row[id].'">EDIT</a>'; echo '<a href="deletepage.php?id='.$row[id].'">DELETE</a>' But I do not want each line editted individually. This would take forever for my schedulers to edit their schedules. I have 1500 games to be editted, and some clubs have to edit for >150 games each. This is what I have to display the requested information: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; if (isset($readmore) && !isNum($readmore)) fallback(FUSION_SELF); opentable("Team Contacts"); // mySQL Table $db_con = mysql_connect(MyHost, MyUsername, MyPassword) or die("Connetion to database failed!"); mysql_select_db(MyDatabase); $age = $_GET['club']; $sql = "SELECT club, age, date, time_notes, time, cemail, home, visitors, field FROM MyTable WHERE club='$club'"; $result = mysql_query($sql) or die(mysql_error()); $i = 0; echo "<font face='Arial' size='4' color='#000000'><b>Team contacts for all divisions of $age:</b></font><p style='margin-top: 0'> <font face='Arial' size='3'>To update your team's contact listing, <u> <font color='#0000ff'><a href='http://www.myrsl.org/viewpage.php?page_id=43'> <font color='#0000cc'>click here<br></font></a></font></u></font><br><br>\n\n"; echo "</p> <table width='100%' border='1' cellspacing='0' cellpadding='5' bordercolorlight='#000000' bordercolordark='#000000'><tr> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Club</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Age</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Date</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Time/Notes</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Time</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Home Team</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Visiting Team</font></th> <th align='left' bgcolor='#FF0000' style='border-style: solid; border-width: 1px' bordercolor='#000000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' color='#FFFFFF' size='2'>Field</font></th> </tr>'; while ($row = mysql_fetch_array($result)) { echo '<tr> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <font face='Arial' size='1'>' . $row['club'] . "</font></td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>' . $row['age'] . '</font><p style='margin-top: 0; margin-bottom: 0'> <font face='Arial' size='1'> </font><p style='margin-top: 0; margin-bottom: 0'> <font face='Arial' size='1'> </font></td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>' . $row['date'] . '</font></td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>' . $row['time_notes'] . '</font></td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>' . $row['time'] . '</font></td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>" . $row['home'] . "</font></td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>' . $row['visitors'] . '</font></p> </td> <td valign='top' style='border-style: solid; border-width: 1px' bordercolor='#ff0000' bordercolorlight='#ff0000' bordercolordark='#000000'> <p style='margin-top: 0; margin-bottom: 0'><font face='Arial' size='1'>' . $row['field'] . '</font></p> </td> </tr>'; } echo '</table>\n"; // mySQL ends closetable(); require_once "side_right.php"; require_once "footer.php"; ?> In my scheduling process, all data is included in the MySQL table with exception of "Time" ($row['time']) and "Field" ($row['field']). That information is determined by Club Field Schedulers. Those two columns in my table are where I can Text Fields for input. Assistance is greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/#findComment-178797 Share on other sites More sharing options...
netpants Posted February 7, 2007 Share Posted February 7, 2007 I think it would be somthing similar to this , I am not a good with php so maybe wait for someone else but maybe this will trigger somthing in your mind. <form action="update.php" method="post"> <td class="bodycell4" width="50%" align="right"> <b>Time:</b> <td class="bodycell4" width="50%"> <input name="timeAGE7" type="password" size="30"> </td> </tr> <tr> <td class="bodycell4" width="50%" align="right"> <b>Field:</b> </td> <td class="bodycell4" width="50%"> <input name="fieldAGE7" type="text" size="30"> </td> </tr> <input name="update" type="submit" value="Submit"> $time7=strip_tags(stripslashes($_POST['timeAGE7'])); $field7=strip_tags(stripslashes($_POST['fieldAGE7'])); $query = "INSERT INTO `Schedule` "; $query .= "( `TimeTableAge7` , `FieldTableAge7`) "; $query .= "VALUES (\"$time7\", \"$field7\")"; Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/#findComment-178799 Share on other sites More sharing options...
kemper Posted February 7, 2007 Author Share Posted February 7, 2007 Thanks. But, I want to mysql_query then batch edit that result. Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/#findComment-178805 Share on other sites More sharing options...
Hypnos Posted February 7, 2007 Share Posted February 7, 2007 Use UPDATE querys with a POST form. I can't really give you a simple example of good code that will do this. Although, it would be easier if your table had a primary key. Does it? Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/#findComment-178827 Share on other sites More sharing options...
kemper Posted February 7, 2007 Author Share Posted February 7, 2007 No, I have not set Primary Key Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/#findComment-178844 Share on other sites More sharing options...
kemper Posted February 7, 2007 Author Share Posted February 7, 2007 I guess I could add new field "clubid" and use as Primary Key. How would this make a difference or make it easier? Link to comment https://forums.phpfreaks.com/topic/37400-form-to-update-mysql-table/#findComment-178852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.