如果在创建此页面时出现错误,请您告诉我一下吗? 我想为virtuemart做搜索组件,我使用一个php文件,我写了整个代码。我想使用数组变量send2 []和添加新的选择选项为$ compare2变量添加新条件。请问您有什么建议吗?我不是专家。谢谢
<?php
$con=mysqli_connect("","","","");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (isset($_POST['Submit'])) {
$compare1 = $_POST['send1'];
?>
?>
<table border="1" cellspacing="2" cellpadding="2">
<?php
for ($i=0; $i<sizeof($compare1);$i++) {
$result = mysqli_query($con,"SELECT * FROM auto_virtuemart_products WHERE '$compare1[$i]' LIKE product_sku");
?>
<?php
while($row = mysqli_fetch_array($result))
{
?>
<tr>
<td>
<?php echo $row['product_sku'];?>
</td>
<td>
<?php echo $row['product_weight'];?>
</td>
</tr>
<?php
}
}
?>
</table>
<?php
echo "<input type='button' value='spat' onclick=location.href=''>";
}
else
{
?>
<table border="1" cellspacing="2" cellpadding="2">
<?php
$result = mysqli_query($con,"SELECT * FROM auto_virtuemart_products");
while($row = mysqli_fetch_array($result)) {
?>
<select>
<option><?php echo $row['product_sku']; ?></option>
</select>
<form method="post">
<input type="checkbox" name="send2" value="<?php echo $row['product_sku'] ?>" />
<?php
}
?>
</table>
<input type="Submit" name="Submit2" value="Vyber"/></form>
<table border="1" cellspacing="2" cellpadding="2">
<?php
if (isset($_POST['Submit2'])) {
$compare2 = $_POST['send2'];
$result = mysqli_query($con,"SELECT * FROM auto_virtuemart_products WHERE '$compare2' LIKE product_sku");
while($row = mysqli_fetch_array($result)) {
?>
<tr>
<td>
<font face="Arial, Helvetica, sans-serif"><?php echo $row['product_sku']; ?></font>
</td>
<td>
<font face="Arial, Helvetica, sans-serif"><?php echo $row['product_weight']; ?></font>
</td>
<td>
<form method="post">
<input type="checkbox" name="send1[]" value="<?php echo $row['product_sku'] ?>" />
</td>
</tr>
<?php
}
}
else
{
echo "Empty";
}
mysqli_close($con);
?>
</table>
<input type="Submit" name="Submit" value="Submit"/></form>
<?php
}
?>