Jump to content

form to update MySQL Table


kemper

Recommended Posts

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:

tableform.jpg

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

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.

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\")";

 

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.