www.webdeveloper.com
Results 1 to 3 of 3

Thread: update form array not working.

  1. #1
    Join Date
    Sep 2010
    Posts
    38

    update form array not working.

    Hi,

    My update form array does not work.



    I am trying to upload to two tables: matches and matchscores



    I need to upload to matchsores twice as it must hold information for two teams per match_id



    This is my HTML

    PHP Code:
           <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>
                    <td height="25" bgcolor="#000000" class="tableTextHeading"><div align="center">Update</div></td>
                  </tr>

                  <?php do { ?>
     <form action="<?php echo $editFormAction?>" method="POST" name="fixtures"> 
                    <tr>
                     
                      <td><div align="center"><span id="sprytextfield1">
                        <label>
                        <input name="date[]" type="text" class="date" size="8" style="text-align:center" value="<?php echo $row_match_fixtures['shortDate']; ?>" />
                        <span class="textfieldRequiredMsg">A value is required.</span>                            
                        </label>
                        </span></div></td>
                      <td><div align="center"><a href="match-player.php?id=<?php echo $row_match_fixtures['match_id']; ?>&team=<?php echo $row_match_fixtures['team1_id']; ?>"><?php echo $row_match_fixtures['team1_name']; ?></a></div></td>
                      <td><div align="center"><input name="s1[]" type="text" value="<?php echo $row_match_fixtures['score1']; ?>" size="1" style="text-align:center" /> 
                      v <input name="s2[]" type="text" value="<?php echo $row_match_fixtures['score2']; ?>" size="1" style="text-align:center" />
                      </div></td>
                      <td><div align="center"><a href="match-player.php?id=<?php echo $row_match_fixtures['match_id']; ?>&team=<?php echo $row_match_fixtures['team2_id']; ?>"><?php echo $row_match_fixtures['team2_name']; ?></a></div></td>
                      <td><div align="center"><span id="sprytextfield2">
                      <label>
                      <input name="time[]" type="text" size="3" value="<?php echo $row_match_fixtures['time']; ?>" style="text-align:center" />
                      </label>
                      <span class="textfieldInvalidFormatMsg">Invalid format.</span><span class="textfieldRequiredMsg">A value is required.</span></span></div></td>
                      <td><div align="center"><span id="spryselect1">
                        <label>
                        <select name="venue[]">
                          <?php
    do {  
    ?>
                          <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($venue0);
           
    $row_venue mysql_fetch_assoc($venue);
      }
    ?>
                        </select>
                        </label>
                        <span class="selectRequiredMsg">Please select an item.</span></span></div></td>
                      <td><div align="center"><span id="spryselect2">
                        <label>
                        <select name="referee[]">
                          <?php
    do {  
    ?>
                          <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($referee0);
           
    $row_referee mysql_fetch_assoc($referee);
      }
    ?>
                        </select>
                        </label>
                        <span class="selectRequiredMsg">Please select an item.</span></span></div></td>

                      <td><div align="center"><input name="Submit[]" type="submit" id="Submit" value="Save" /></div></td>

               
                    </tr>
             <input name="match_id[]" type="hidden" value="<?php echo $row_match_fixtures['match_id']; ?>" />
            <input name="mscore1[]" type="hidden" value="<?php echo $row_match_fixtures['mscore1']; ?>" />
            <input name="mscore2[]" type="hidden" value="<?php echo $row_match_fixtures['mscore2']; ?>" />
            <input name="team1_id[]" type="hidden" value="<?php echo $row_match_fixtures['team1_id']; ?>" />
            <input name="score1[]" type="hidden" value="<?php echo $row_match_fixtures['score1']; ?>" />
            <input name="team2_id[]" type="hidden" value="<?php echo $row_match_fixtures['team2_id']; ?>" />
            <input name="score2[]" type="hidden" value="<?php echo $row_match_fixtures['score2']; ?>" />
            
            <input type="hidden" name="MM_update" value="fixtures" />                  
    </form> 
                    <?php } while ($row_match_fixtures mysql_fetch_assoc($match_fixtures)); ?>
          
                </table></td>
              </tr>
            </table>
    PHP Code:
    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "fixtures")) {
      
    $updateSQL sprintf("UPDATE matches SET `date`=%s, `time`=%s, referee_id=%s, venue_id=%s WHERE match_id=%s",
                           
    GetSQLValueString($_POST['date'], "date"),
                           
    GetSQLValueString($_POST['time'], "text"),
                           
    GetSQLValueString($_POST['referee'], "int"),
                           
    GetSQLValueString($_POST['venue'], "int"),
                           
    GetSQLValueString($_POST['match_id'], "int"));
                                
      
    $updateSQL sprintf("UPDATE matchscores SET match_id=%s, team=%s, score=%s WHERE matchscores_id=%s",
                           
    GetSQLValueString($_POST['match_id'], "int"),
                           
    GetSQLValueString($_POST['team1_id'], "int"),
                           
    GetSQLValueString($_POST['score1'], "int"),
                           
    GetSQLValueString($_POST['mscore1'], "int"));
                                
      
    $updateSQL sprintf("UPDATE matchscores SET match_id=%s, team=%s, score=%s WHERE matchscores_id=%s",
                           
    GetSQLValueString($_POST['match_id'], "int"),
                           
    GetSQLValueString($_POST['team2_id'], "int"),
                           
    GetSQLValueString($_POST['score2'], "int"),
                           
    GetSQLValueString($_POST['mscore2'], "int"));

      
    mysql_select_db($database_db$db);
      
    $Result1 mysql_query($updateSQL$db) or die(mysql_error());

      
    $updateGoTo "fixtures-edit.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
        
    $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$updateGoTo));

    PHP Code:
    mysql_select_db($database_db$db);
    $query_match_fixtures "select m.match_id, date_format(m.date, '%W %D %M %Y') as mDate, date_format(m.date, '%d/%m/%Y') as shortDate, m.time, t1.team_id as team1_id, t1.division, m.report, t1.team_name as team1_name, s1.score as score1, t2.team_id as team2_id, t2.team_name as team2_name, s2.score as score2, v.venue_name, r.fname, r.sname, s1.matchscores_id as mscore1, s2.matchscores_id as mscore2 
    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 by match_id 
    order by 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); 
    Where am I going wrong?

  2. #2
    Join Date
    Sep 2010
    Posts
    38
    Can anyone tell me how to create a loop so that my form gets looped so that I have many of the same form?

    And then insert into two tables?
    I need to update one table and insert into two others

  3. #3
    Join Date
    Sep 2010
    Posts
    38
    I cannt seem to get this to work at all.
    Does anyone know a good tutorial or something that can help me?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13242 seconds
  • Memory Usage 2,946KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates