/    Sign up×
Community /Pin to ProfileBookmark

Show multiple images but not selectoptions

Hello,

I need help with some code because I cant figure it out on my own?

This is my Class:

[code=php]<?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 LIMIT 1″;
}
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);
}
}

?>[/code]

And this is my code for the output:

[code=php]<?php
include_once “class/merken.class.php”;
$merkclass = new merken($dbo);
?>
<br />
<div class=”bandwielkolom”>
<form action=”index.php?lang=nl&amp;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 “ttttttttttt<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>&nbsp;</td>
<td><input type=”submit” name=”wiel_submit” value=”Zoek” /></td>
</tr>
<tr>
<td colspan=”2″>&nbsp;</td>
</tr>
<tr>
<td colspan=”2″>&nbsp;</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);
?>
<img src=”http://www.etyre.net/preview/bnet/logos/<?php echo str_replace(“.png”, “_150.png”, $merken[0]->merk_logo); ?>” width=”150″ class=”logo” alt=”<?php echo $merken[0]->merk_naam; ?>”/>
<div id=”merken”>
<li><span class=”title”>Foto <?php echo $merken[0]->wiel_foto; ?></span>
<a href=”http://www.inter-tyre.nl/inter-tyre/images/w3/<?php echo $merken[0]->wiel_foto; ?>” class=”preview” title=”Fotonummer: <?php echo $merken[0]->wiel_foto; ?>”>
<img src=”http://www.inter-tyre.nl/inter-tyre/images/w2/<?php echo $merken[0]->wiel_foto; ?>” alt=”Fotonummer: <?php echo $merken[0]->wiel_foto; ?>” class=”wheelImg”/>
</a>
<div class=”clearboth”></div>
</div>
<?php
}
?> [/code]

What I try to accomplish is the following:

I got a option selectfield and you can select different brands. After you submit you get the name and logo of the brand and the wheel that has that brand.

Now I only have 11 different brands with a wheel but I got more wheels with the same brand and I want to show all the wheels that belong to the brand you selected.

Here is how my database looks like:

[url]http://imageshack.us/photo/my-images/685/databaseh.png[/url]

So lets say I put in another Rosso with a different picture. When I select Rosso and click submit I get 2 wheels of Rosso. The only thing that is happening now is that in my selectbox I can choose Rosse 2 times! And when I add another Rosso wheel I can choose 3 times. Same is with merk_logo that is there 3 times…

Can somebody help me with the code I got this far and help me getting this thing to work like a charm? ?

I know I am very close but just need to fix this…

Thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@JoepioooauthorJul 16.2012 — Hi there again,

Is there nobody that can help me with this? I allready tried DISTINCT but that did not work either..
Copy linkTweet thisAlerts:
@mavigozlerJul 16.2012 — You discuss PHP output, I believe, and discuss the interaction with a form. Perhaps if you include an image of the form and how the user interacts with it, that might generate both more interest in your problem and suggestions in reply.

One more thing: I know it's a bit of work, but if you can actually set up a small version of your script that minimally expresses the problem that you are seeing, that too might help. In your case, you may need to create another database in your MySQL system with the example data. When others can see by interaction the problem you are having, the solution is faster. I have also found that in trying to set up an interactive question, I found the solution to my problem during the set up in 4 out of 5 cases. Crazy, isn't it?
×

Success!

Help @Joepiooo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...