-1

这里有一个简单的代码,我使用了 2 个带有显示和隐藏的表单,所以一切都很好,我只是错过了CL_ID使用第二种表单在不同的桌子上设置

所以我在这里需要什么只是为了插入该行结果.$row['cl_id'].我在第一个查询中得到的内容被插入到第二个表单上什么是正确的并保存了数据'我试着让它向上或向下我所有的问题是“未定义的变量" & 其他"未定义索引"的原因($row= mysql_fetch_assoc($data))

我尝试了所有方法,但我发现定义了它应该是的变量 ($row= mysql_fetch_assoc($data)) { only here } 数组未到达的任何其他地方不可读

<?php
echo"<style type='text/css'>#here{ display:none; } </style> ";
require ('connections.php');
echo"<hr />";
if(isset($_POST['search'])) {
   $search=(trim($_POST['search']));
   if (empty($search)){echo" insert something to search it ";
   } else{
     $data=mysql_query("SELECT * from cl_info INNER JOIN cl_pro ON cl_pro.cl_id=cl_info.id WHERE cl_info.id LIKE '$search'")or die(mysql_error());
     $num=mysql_num_rows($data);
         if($num<1){echo' no results of your search'; }

        else{?> <style type="text/css">#form1{ display:none; }</style>
                <style type="text/css">#here{ display:block; }</style>
        <?php




              while ($row= mysql_fetch_assoc($data)) {
                //$ak=($row['cl_id'])   ;
//                    echo("<hr/>");
//                     echo("$ak");

 echo("<table with='40%'border='1' align='center'>
  <tr>
  <th>  Client ID</th>
  <th>  Name</th>
  <th>  Phone</th>
  <th>  Date of Birth</th>
  <th>  Blood Type</th>
  <th>  E-mail</th>
  <th>  smoker</th>
  <th>  drugs</th>
  <th>  extra</th>
  <th>  extra2</th>
  </tr>


   <tr>
    <td>".$row['cl_id']."</td>
    <td>".$row['name']."</td>
    <td>".$row['phon']."</td>
    <td>".$row['d_birth']."</td>
    <td>".$row['blood_typ']."</td>
    <td>".$row['email']."</td>
    <td>".$row['smoker']."</td>
    <td>".$row['drugs']."</td>
     <td>".$row['extra']."</td>
    <td>".$row['extra2']."</td>

     </tr> ") ; echo"</table>";



     } } } }

 echo"  where it was  form 1


<form id='form1' action=''  method='post'>
<input type='text' name='search' />
<input type='submit' name='sub'  /> </form>


  " ;

  /////// start  open  new form2 "here "//////


 echo"
<form  id='here' action=''    method='post' >

r: <input type='text' name='r' />
Doz :<input type='text' name='doz' />
Time:<input type='text' name='t/d' />
Date <input type='text' name='date' />
<input type='hidden' name='cl_id'  />
<input type='submit' name='submit' value='Insert'  />

</form> ";

      if (isset($_REQUEST['submit'])){
//if (isset($_POST['submit'])){

  echo('you have isset works right');

   $r =$_POST['r'];
   $doz =$_POST['doz'];
   $t =$_POST['t/d'];
   $date =$_POST['date'] ;
   //$clid =$_POST['cl_id'] ;

 mysql_query ("INSERT INTO scri (id, cl_id, r, doz, time, date) VALUES ('', '$ak', '$r', '$doz', '$t', '$date')")or die ( mysql_error());

}
?>                                 <!---- end of PHP ---->

</body>


</html>
4

1 回答 1

0

好的,试试这个:

 mysql_query ("INSERT INTO scri (id, cl_id, r, doze, time, date) VALUES ('', '$ak', '$r', '$doz', '$t', '$date')")or die ( mysql_error());

这对我有用:)

于 2013-06-05T12:42:26.947 回答