I got this peace of code now and I will explain what is happening and what I want:
[php]
Op merk zoeken
|
Merk: |
- Merk -
<?php
$wielen = $wielclass->getMerkenWielen($website);
$get_wiel = isset($_GET['wiel']) ? $_GET['wiel'] : '';
$post_wiel = isset($_POST['band_merk']) ? $_POST['band_merk'] : '';
foreach($wielen as $wiel) {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$selected = $post_wiel['wiel'] === $wiel->merk_code ? ' selected="selected"' : '' ;
}
else {
$selected = $get_wiel['wiel'] === $wiel->merk_code ? ' selected="selected"' : '' ;
}
echo '\t\t\t\t\t\t\t\t\t\t\t' . $wiel->merk_naam . '';
}
?>
</select>
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="band_submit" value="Zoek"/></td>
</tr>
</table>
</form>
</div>
<?php
if(isset($_POST[‘band_submit’]) && $_POST[‘band_merk’] == $wiel->merk_code)
echo $wiel->merk_naam;
?>[/php]
Precess code:
[php]if(isset($_POST[‘band_submit’]) && $_POST[‘band_merk’] == $wiel->merk_code)
echo $wiel->merk_naam;[/php]
My Class
[php]<?php
class wielen extends connect
{
private $wielenlijst;
public function getMerkenWielen($database)
{
$sql = "SELECT * FROM ".$database."_wielen ORDER BY merk_nummer";
try
{
$stmt = $this->db->prepare($sql);
$stmt->execute();
$this->wielenlijst = $stmt->fetchAll(PDO::FETCH_OBJ);
$stmt->closeCursor();
return $this->wielenlijst;
}
catch (Exception $e)
{
die ($e->getMessage());
}
}
public function __construct($dbo)
{
parent::__construct($dbo);
}
}
?>
[/php]
I get a selectbox with four options out of my database so that is working correct. These options has data in it like a picture and text. When I select one and press submit he has to show the information of the selected option and that should stay selected.
What is happening now is that when I select a option and press submit nothing happens… The button is working but I dont get any output of the selected option and it wont stay selected.
Doing something wrong but I cant figure out what
Any help is welcome:)
|