我正在尝试合并到表格中。我有 11 个不同的品牌,我有属于一个品牌的轮子。您可以使用选项选择框按名称选择品牌,当我想要使用该品牌的所有轮子时。
这是我正在使用的课程:
<?php
include_once "connect.class.php";
class merken extends connect
{
private $merkenlijst;
public function getMerken($database, $id = NULL)
{
$sql = "SELECT * FROM ".$database."_merken";
if(!empty($id))
{
$sql .= " WHERE merk_code=:id";
}
else
{
$sql .= " ORDER BY merk_naam ASC";
}
try
{
$stmt = $this->db->prepare($sql);
if(!empty($id)){ $stmt->bindParam(":id", $id, PDO::PARAM_STR); }
$stmt->execute();
$this->merkenlijst = $stmt->fetchAll(PDO::FETCH_OBJ);
$stmt->closeCursor();
return $this->merkenlijst;
}
catch (Exception $e)
{
die ( $e->getMessage() );
}
}
public function __construct($dbo = NULL)
{
parent::__construct($dbo);
}
}
?>
这就是我从数据库中回显信息的方式:
<div class="bandwielkolom">
<form action="index.php?lang=nl&p=<?php echo $_GET['p']; ?>#keuze" method="post">
<table class="bandentabel">
<tr>
<th colspan="2">Zoek op merk<a name="wiel"></a></th>
</tr>
<tr>
<td>Merk:</td>
<td>
<select name="wiel_merk">
<option value="0">- Merk -</option>
<?php
$merken = $merkclass->getMerken($website);
foreach($merken as $merk)
{
echo "\t\t\t\t\t\t\t\t\t\t\t<option value=\"".$merk->merk_code."\"";
if(isset($_GET['search']) && $_GET['search'] == "wiel" && isset($_GET['merk']) && $_GET['merk'] == $merk->merk_code || isset($_POST['wiel_submit']) && $_POST['wiel_merk'] == $merk->merk_code) { echo " selected=\"selected\""; }
echo ">".$merk->merk_naam."</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="wiel_submit" value="Zoek" /></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
</table>
</form>
</div>
<div class="clearboth"></div>
<br />
<?php
if(isset($_POST['wiel_submit']) && $_POST['wiel_submit'] == "Zoek" || isset($_GET['merk']))
{
$merk = NULL;
if(isset($_POST['wiel_submit']) && $_POST['wiel_submit'] == "Zoek")
{
$merk = $_POST['wiel_merk'];
}
$merken = $merkclass->getMerken($website, $merk);
foreach($merken as $merk)
{
?>
<img src="http://www.etyre.net/preview/bnet/logos/<?php echo str_replace(".png", "_150.png", $merk->merk_logo); ?>" width="150" class="logo" alt="<?php echo $merk->merk_naam; ?>"/>
<div id="merken">
<li><span class="title"><?php echo $merk->wiel_info; ?></span>
<a href="http://www.inter-tyre.nl/inter-tyre/images/w3/<?php echo $merk->wiel_foto; ?>" class="preview" title="Fotonummer: <?php echo $merk->wiel_foto; ?>">
<img src="http://www.inter-tyre.nl/inter-tyre/images/w2/<?php echo $merk->wiel_foto; ?>" alt="Fotonummer: <?php echo $merk->wiel_foto; ?>" class="wheelImg"/>
</a>
<div class="clearboth"></div>
</div>
<?php
}
?>
<?php
}
?>
我怎样才能将这两个表连接在一起,而不是当我选择一个品牌时,它会显示所有具有该品牌的车轮?在我的选择中没有双重品牌?
merken table 有人可以帮帮我吗?
谢谢