insert/update into two tables with loop


hi,

i have form, , have looping current page loops athrough football teams play each other.

 

i have added field data , added addt date picker not adding other date fields

 

i need know how can insert data 2 tables list, , not create doubles of matches

 

i have removed data picker not add each

<input type="text" name="date" id="date" tabindex="1" />

 

  query getting paired teams

mysql_select_db($database_db, $db);
$query_match_fixtures = "select m.match_id, date_format(m.date, '%w %d %m %y') mdate, m.time, t1.division, m.report, t1.team_name team1_name, s1.score score1, t2.team_name team2_name, s2.score score2, v.venue_name, r.fname, r.sname 
from matches m left join (matchscores s1 left join team t1 on t1.team_id = s1.team) on (s1.match_id = m.match_id) left join (matchscores s2 left join team t2 on t2.team_id = s2.team) on (s2.match_id = m.match_id)
left join referee r on r.ref_id = m.referee_id left join venue v on v.venue_id = m.venue_id
where s1.team <> s2.team
group match_id
order m.match_id";
$match_fixtures = mysql_query($query_match_fixtures, $db) or die(mysql_error());
$row_match_fixtures = mysql_fetch_assoc($match_fixtures);
$totalrows_match_fixtures = mysql_num_rows($match_fixtures);

 

 

this table list of matches shown.

i have modified include form, not sure how part working

 

<h2><?php echo $row_match_fixtures['mdate']; ?></h2>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
               
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">date</div></td>
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">home</div></td>
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">score</div></td>
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">away</div></td>
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">kick-off</div></td>
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">venue</div></td>
                <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">referee</div></td>
               
              </tr>
              <?php { ?>
                <tr>
<form action="" method="post" name="fixtures">                 
                  <td><div align="center"><span id="sprytextfield1">
                    <label>
                    <input type="text" name="date" id="date" tabindex="1" />
                    <span class="textfieldrequiredmsg">a value required.</span>                            </label>
                    </span></div></td>
                  <td><div align="center"><?php echo $row_match_fixtures['team1_name']; ?></div></td>
                  <td><div align="center"><?php echo $row_match_fixtures['score1']; ?> v <?php echo $row_match_fixtures['score2']; ?></div></td>
                  <td><div align="center"><?php echo $row_match_fixtures['team2_name']; ?></div></td>
                  <td><div align="center"><?php echo $row_match_fixtures['time']; ?></div></td>
                  <td><div align="center"><?php echo $row_match_fixtures['venue_name']; ?></div></td>
                  <td><div align="center"><?php echo $row_match_fixtures['fname']; ?> <?php echo $row_match_fixtures['sname']; ?></div></td>
                  <td>
                  </td>
</form>                 
                </tr>
                <?php } while ($row_match_fixtures = mysql_fetch_assoc($match_fixtures)); ?>
            </table></td>
          </tr>
        </table>

this wat have

 

my database

 

create table if not exists `matches` (
  `match_id` int(8) not null auto_increment,
  `date` date default null,
  `time` varchar(5) default null,
  `report` longtext,
  `referee_id` int(8) not null,
  `season_id` int(8) not null,
  `venue_id` int(8) not null,
  primary key  (`match_id`),
  key `referee_id` (`referee_id`),
  key `venue_id` (`venue_id`)
) engine=myisam  default charset=latin1 auto_increment=21 ;

 

create table if not exists `matchscores` (
  `matchscores_id` int(8) not null auto_increment,
  `match_id` int(8) not null,
  `team` int(8) not null,
  `score` int(8) default null,
  primary key  (`matchscores_id`),
  key `match_id` (`match_id`,`team`)
) engine=myisam  default charset=latin1 auto_increment=39 ;

 

<form action="" method="post" name="fixtures">          <table width="100%" border="0" cellspacing="0" cellpadding="0">           <tr>             <td><table width="100%" border="0" cellspacing="0" cellpadding="0">               <tr>                                  <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">date</div></td>                 <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">home</div></td>                 <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">score</div></td>                 <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">away</div></td>                 <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">kick-off</div></td>                 <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">venue</div></td>                 <td height="25" bgcolor="#000000" class="tabletextheading"><div align="center">referee</div></td>                                </tr>                <?php { ?>                 <tr>                                     <td><div align="center"><span id="sprytextfield1">                     <label>                     <input name="date" type="text" class="date" size="10" style="text-align:center" />                     <span class="textfieldrequiredmsg">a value required.</span>                                                 </label>                     </span></div></td>                   <td><div align="center"><?php echo $row_match_fixtures['team1_name']; ?></div></td>                   <td><div align="center"><input name="s1" type="text" value="<?php echo $row_match_fixtures['score1']; ?>" size="2" style="text-align:center" />                    v <input name="s2" type="text" value="<?php echo $row_match_fixtures['score2']; ?>" size="2" style="text-align:center" />                   </div></td>                   <td><div align="center"><?php echo $row_match_fixtures['team2_name']; ?></div></td>                   <td><div align="center"><span id="sprytextfield2">                   <label>                   <input name="time" type="text" size="6" value="<?php echo $row_match_fixtures['time']; ?>" style="text-align:center" />                   </label>                   <span class="textfieldinvalidformatmsg">invalid format.</span><span class="textfieldrequiredmsg">a value required.</span></span></div></td>                   <td><div align="center"><span id="spryselect1">                     <label>                     <select name="venue">                       <?php {   ?>                       <option value="<?php echo $row_venue['venue_id']?>"<?php if (!(strcmp($row_venue['venue_id'], $row_venue['venue_name']))) {echo "selected=\"selected\"";} ?>><?php echo $row_venue['venue_name']?></option>                       <?php } while ($row_venue = mysql_fetch_assoc($venue));   $rows = mysql_num_rows($venue);   if($rows > 0) {       mysql_data_seek($venue, 0);        $row_venue = mysql_fetch_assoc($venue);   } ?>                     </select>                     </label>                     <span class="selectrequiredmsg">please select item.</span></span></div></td>                   <td><div align="center"><span id="spryselect2">                     <label>                     <select name="referee">                       <?php {   ?>                       <option value="<?php echo $row_referee['ref_id']?>"<?php if (!(strcmp($row_referee['ref_id'], $row_referee['sname']))) {echo "selected=\"selected\"";} ?>><?php echo $row_referee['fname']?> <?php echo $row_referee['sname']?></option>                       <?php } while ($row_referee = mysql_fetch_assoc($referee));   $rows = mysql_num_rows($referee);   if($rows > 0) {       mysql_data_seek($referee, 0);        $row_referee = mysql_fetch_assoc($referee);   } ?>                     </select>                     </label>                     <span class="selectrequiredmsg">please select item.</span></span></div></td>                   <td>                   </td>                              </tr>                 <?php } while ($row_match_fixtures = mysql_fetch_assoc($match_fixtures)); ?>                    </table></td>           </tr>         </table> <br />      <br />          <br />         <input name="submit" type="submit" id="submit" value="update" />                   </form> 


More discussions in Develop server-side applications in Dreamweaver


adobe

Comments

Popular posts from this blog

Hur installera Joomla på One.com - Joomla! Forum - community, help and support

removing index.php from URL address - Joomla! Forum - community, help and support

「イメージマップのアンカー名には、...」のエラーが出ないようにしたい