Jump to content

Combine two forms on two separate tables


bschultz

Recommended Posts

I have a page that has two forms.

 

Form 1:

 

- list baseball game information (who is playing, what time is the game, etc)

 

Form 2:

 

- lists umpires scheduled to work that game

 

 

I would like to combine this to one form...to edit the info in the database (edit the start time, date etc...AND to edit the umpires scheduled to work the game...ON ONE FORM.

 

Here's what I currently have:

 

<?php
$conn1 = mysql_connect($host, $username, $password);
if (!$conn1) {
   echo "Unable to connect to DB: " . mysql_error();
   exit;
}
if (!mysql_select_db($db, $conn1)) {
   echo "Unable to select mydbname: " . mysql_error();
   exit;
}

$sql = "SELECT * from games WHERE `game_id` = '$_GET[game]' AND `association_id` = '$_SESSION[association_id]'";

$rs = mysql_query($sql,$conn1);
$matches = 0; 
while ($row = mysql_fetch_assoc($rs))  {
$matches++; 
?>


<form method="POST" action="edit_db_1_game.php">

  <p>
  <input name="game_id" type="hidden" id="game_id" size="10" maxlength="10"  value="<?php echo $row[game_id];  ?>" />
  <br />
  <strong><br />
    THIS SECTION OF THE PAGE WILL EDIT THE GAME INFO...IF YOU WANT TO EDIT OFFICIALS, DO SO BELOW.</strong><br />
  <br />
    Date of game - 
  <input name="day" type="text" id="day" size="10" maxlength="10"  value="<?php echo $row[day];  ?>" />
  <br />
  <br />
    Sport - 
  <input name="sport" type="text" id="sport" size="20" maxlength="20"  value="<?php echo $row[sport];  ?>" />
  <br />
  <br />
    Visitor
  <input name="visitor" type="text" id="visitor" size="50" maxlength="50"  value="<?php echo $row[visitor];  ?>" />
  <br />
  <br />
    Home
  <input name="home" type="text" id="home" size="50" maxlength="50"  value="<?php echo $row[home];  ?>" />
  <br />
  <br />
    Start
  <input name="start" type="text" id="start" size="10" maxlength="30"  value="<?php echo $row[start];  ?>" />
  <br />
  <br />
    Notes
  <input name="notes" type="text" id="notes" size="50" maxlength="200"  value="<?php echo $row[notes];  ?>" />
  <?php
echo "<br /><br />Send Email? <label><input type='checkbox' name='send_email' id='send_email' value='1' /></label><br /><br />";  
?>
  <input name="submit" type="submit" value="Submit" />     </form>
  <?php
}
if (! $matches) { 
echo ("<br /><br />There are no matches for this game ID"); 


}  


?>
    
  <br />
  <br />
    -----------------------------------------------------------------------------------------------<br />
  </p>
  <p><strong>THIS SECTION OF THE PAGE WILL EDIT THE SCHEDULED OFFICIALS...IF YOU WANT TO EDIT GAME INFO, DO SO ABOVE.<br />
    <br />
  </strong>The officials scheduled for this game are: <br /><br />
  <?php 
$dbc = mysql_pconnect($host, $username, $password);  
mysql_select_db($db,$dbc); 
$sql = "SELECT first_name, last_name, ump_id FROM ump_names WHERE `ump_id` IN (SELECT ump_id, row AS thisrow FROM scheduled_umps WHERE `game_id` = '$_GET[game]')"; 
//echo "$sql<br />";
$rs = mysql_query($sql,$dbc);  

$num_rows = mysql_num_rows($rs);
echo "<form method='POST' action=''>";

$r = 1;
while ($r <= $num_rows)
{

while($row = mysql_fetch_array($rs)) 
            {
  echo "<label><input type='radio' name='tba[$r]' id='tba[$r]' value='1' /></label>  Set <b>$row[first_name] $row[last_name]</b> to TBA<br />";
   echo "<label><input type='hidden' name='tbarow[$r]' id='tbarow[$r]' value='thisrow' /></label>";
   
    echo "<label><input type='radio' name='delete[$r]' id='delete[$r]' value='1' /></label>  Delete the \"slot\" for <b>$row[first_name] $row[last_name]</b> permanently - (IE you need one fewer official than you thought)<br /><br />";
    echo "<label><input type='hidden' name='deleterow[$r]' id='deleterow[$r]' value='thisrow' /></label>";
$r++;
}
		}

?>

 

This works...but it's on two forms (which makes the "update db" script kinda clumsy). 

 

I've never done a table join to anything like it (which I'm assuming is what will make this work better)...but how can I combine this to one form...and add an "update db" section to the code?

 

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.