这里有一个简单的代码,我使用2个带有节目和隐藏的表单,所以一切都很好,我只是错过了使用第二种形式在另一个表上设置CL_ID
所以我需要的只是插入行.$row['cl_id'].
我在第一个查询中获得的内容插入到第二个表单上的内容是否正确并保存了数据'
我试过把它弄清楚我的问题是什么" undefined变量" &安培;其他"未定义的索引" ($row= mysql_fetch_assoc($data))
我尝试了一切,但我发现定义变量应该是($ row = mysql_fetch_assoc($ data)){仅此处}任何其他数据未达到不可读的地方
<?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>
答案 0 :(得分:0)
好的,试试这个:
mysql_query ("INSERT INTO scri (id, cl_id, r, doze, time, date) VALUES ('', '$ak', '$r', '$doz', '$t', '$date')")or die ( mysql_error());
这对我有用:)