正如您所看到的,我在我的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