如何使用jquery表单与php循环不止一次

时间:2011-11-28 00:23:09

标签: php javascript jquery html

我尝试运行while循环,我也希望jquery表单处理它,以便页面不刷新。到目前为止代码工作,但它只在第一个循环上使用了jquery函数,而其他循环则打开了新页面。我需要一些帮助解决这个问题。提前致谢...     (代码)

    $query = mysql_query("SELECT * FROM linkUP_message WHERE to_mem='$from_mem'
            AND to_mem_burn='2' AND new_message='3' ORDER BY id DESC");
    $num_rows = mysql_num_rows($query);
        if ($num_rows < 1) {
    echo '<div id="new_message" class="addlinkuplinks a">&nbsp;You have no 
            message at this time.&nbsp;</div>';
    }else {
        while($row = mysql_fetch_array($query)){
            $msg_id = $row['id'];
            $msg_to_mem = $row['to_mem'];
            $msg_from_mem = $row['from_mem'];
            $msg_from_memID = $row['from_memID'];
            $msg_subject = $row['subject'];
            $msg_content = $row['content'];
            $msg_date = $row['date'];
            $msg_from_mem_burn = $row['from_mem_burn'];
            $msg_to_mem_burn = $row['to_mem_burn'];


      $sqlName=mysql_query("SELECT * FROM prociallinkup_members WHERE 
              email<>'$from_mem' AND email='$msg_from_mem' LIMIT 1")or die ("Sorry we
              have a mysql error!");
      while($row=mysql_fetch_array($sqlName)){
          $msg_from_memAccount=$row["accountType"];
          $msg_from_memID=$row["hdw_id"];
          $msg_from_memEmail=$row["email"];
          $msg_from_memfirstName=$row["firstName"];
          $msg_from_memlastName=$row["lastName"];
          $msg_from_mem_pic=$row["profile_pic"];
          $gender=$row["gender"];}


      echo '

     <div id="linkUPmsg" class="linkUPmsg">
     <table width="100%">
       <tr>
       <tr><td width="60%"align="left" valign="top"><span style="font-size:
               12px; color: #CCCCCC;">Read Date:</span></td>
             <td width="40%"align="right" valign="top"><span style="font-size: 12px;
                color: #CCCCCC;">'.$msg_date.'</span></td>
       </tr>
     <table width="100%">
     <tr>
     <td width="5%" align="left">'.$profile_pic.'</td>
      <td width="87%"align="left" ><span style="font-size: 14px; font-weight:
    bold; color: #999999;">'.$msg_from_memfirstName.' '.$msg_from_memlastName.'</span>
      <div id="requestlinkUP_text">Send you this message!</div>
      <div id="requestlinkUP_text"">Subject: <span style="font-size: 12px; 
     font-weight: bold; color: #0066CC;">'.$msg_subject.'</span></div>
      </td>

      <div id="readmember_msg"></div>
     <td width="3%" align="right"><div id="linkUPmsg_readR"><form id="readForm"
  action="read_message.php" class="readform" method="get" enctype="multipart/form-data"
   name="acceptlinkUP">
     <input name="RfirstName" id="RfirstName" type="hidden"
   value="'.$msg_from_memfirstName.'" />
     <input name="RlastName" id="RlastName" type="hidden" 
   value="'.$msg_from_memlastName.'" />
     <input name="Remail" id="Remail" type="hidden" 
   value="'.$msg_from_memEmail.'" />
    <input name="Rdate" id="Rdate" type="hidden" value="'.$msg_date.'" />
     <input name="Rcontent" id="Rcontent" type="hidden" 
    value="'.$msg_content.'" />
     <input name="Rsubject" id="Rsubject" type="hidden"
   value="'.$msg_subject.'" />
     <input name="Rmsg_id" id="Rmsg_id" type="hidden" value="'.$msg_id.'" />
     <input name="Rto_mem" id="Rto_mem" type="hidden" value="'.$msg_from_mem.'"
              />
     <input name="read_linkUPmsg" class="msgAction" type="image" 
    src="/image/read_mail.png" width="25" height="25"/>
    </form></div></a>

     </td>


      <td width="5%" align="right"><div id="linkUPmsg_burnR"
      class="addlinkuplinks"><form id="burnForm_read" action="/burn_message.php" 
      class="burnForm_read" method="get" enctype="multipart/form-data"
      name="burnlinkUP">
      <input name="msg_id" type="hidden" value="'.$msg_id.'" />
      <input name="to_mem" type="hidden" value="'.$msg_from_mem.'" />
     <input name="burn_linkUPmsg" class="msgAction" type="image"
       src="/image/burn_sign.png" width="20" height="25"/>
     </form></div><div id="burnmember_msg"></div></a>
    </td>

      </tr>
      </table>
      </span>
      </div>
      &nbsp;
              <script type="text/javascript" src="/jquery.js"></script>
    <script type="text/javascript" src="/jquery.form.js"></script>
    <script type="text/javascript" src="/jquery.validate.js"></script>  

      <script type="text/javascript">
      $("document").ready(function()
      {

      $("#burnForm_read").ajaxForm( {
      target: "#burnmember_msg",
      success: function() { 
      $("#linkUPmsg_readR").hide();
      $("#linkUPmsg_burnR").hide(); 


  } 
  });
  });
  </script> 

   ';
}
   }

1 个答案:

答案 0 :(得分:1)

您需要将数组用于输入类型名称,如;

<input name="Rdate[]" id="Rdate" type="hidden" value="'.$msg_date.'" />
//do this for all your input fields
//and the on php side do 
print_r($_POST);