正如您所看到的,我在我的texboxes中出现错误。任何人都可以帮助我解决这个错误?文本框里面文本框内未定义的变量
的错误有以下几种:
**
> aic:
**
<br /><b>Notice</b>: Undefined variable: aic in <b>C:\xampp\htdocs\test\index.php</b> on line <b>34</b><br />
<br /><b>Notice</b>: Undefined variable: aic in <b>C:\xampp\htdocs\test\index.php</b> on line <b>35</b><br />
<br /><b>Notice</b>: Undefined variable: aic in <b>C:\xampp\htdocs\test\index.php</b> on line <b>36</b><br />
<br /><b>Notice</b>: Undefined variable: aic in <b>C:\xampp\htdocs\test\index.php</b> on line <b>37</b><br />
**
> Name List:
**
<br /><b>Notice</b>: Undefined variable: name in <b>C:\xampp\htdocs\test\index.php</b> on line <b>41</b><br />
<br /><b>Notice</b>: Undefined variable: name in <b>C:\xampp\htdocs\test\index.php</b> on line <b>42</b><br />
<br /><b>Notice</b>: Undefined variable: name in <b>C:\xampp\htdocs\test\index.php</b> on line <b>43</b><br />
<br /><b>Notice</b>: Undefined variable: name in <b>C:\xampp\htdocs\test\index.php</b> on line <b>44</b><br />
> **Address:**
<br /><b>Notice</b>: Undefined variable: address in <b>C:\xampp\htdocs\test\index.php</b> on line <b>48</b><br />
<br /><b>Notice</b>: Undefined variable: address in <b>C:\xampp\htdocs\test\index.php</b> on line <b>49</b><br />
<br /><b>Notice</b>: Undefined variable: address in <b>C:\xampp\htdocs\test\index.php</b> on line <b>50</b><br />
<br /><b>Notice</b>: Undefined variable: address in <b>C:\xampp\htdocs\test\index.php</b> on line <b>51</b><br />
PHP代码:
<?php
if(isset($_POST['code'])){
include('include/connect.php');
$batchcode = $_POST['code'];
$sql = mysql_query("SELECT aic,batchcode,address,name FROM tb_app WHERE batchcode LIKE '$batchcode'");
while($rows = mysql_fetch_array($sql)){
$aic[] = $rows['aic'];
$name[] = $rows['name'];
$address[] = $rows['address'];
}
}
?>
的html代码:
Search Batchcode:<input type="text" name="code" id="query" /><br />
<form>
<table>
<tr>
<td>
aic: <br />
<input type="text" name="optA1" value="<?php echo $aic[0] ?>" /> <br />
<input type="text" name="optA2" value="<?php echo $aic[1] ?>" /> <br />
<input type="text" name="optA3" value="<?php echo $aic[2] ?>" /> <br />
<input type="text" name="optA4" value="<?php echo $aic[3] ?>" /> <br />
</td>
<td>
Name List: <br />
<input type="text" name="optB1" value="<?php echo $name[0] ?>" /> <br />
<input type="text" name="optB2" value="<?php echo $name[1] ?>" /> <br />
<input type="text" name="optB3" value="<?php echo $name[2] ?>" /> <br />
<input type="text" name="optB4" value="<?php echo $name[3] ?>" /> <br />
</td>
<td>
Address: <br />
<input type="text" name="optC1" value="<?php echo $address[0] ?>" /> <br />
<input type="text" name="optC2" value="<?php echo $address[1] ?>" /> <br />
<input type="text" name="optC3" value="<?php echo $address[2] ?>" /> <br />
<input type="text" name="optC4" value="<?php echo $address[3] ?>" /> <br />
</td>
</form>
我不希望我的文本框进行循环,因为每个他们有独特的名字,不适合未来使用我的JavaScript。
该通知是相当不言自明的。你从数据库中得到什么结果? – Steve
这是您的代码在您的查询未返回任何行时将生成的内容。在尝试根据假设产生输出之前,您应该检查您的查询是否返回了行。 – Sammitch
@Sammitch我应该怎么做呢?如果行不生成输出,我应该放什么条件? – user3235574