0

heya,
your last answers realy helped me out, but i'm still stuck with another question.
what i want to do is the following.
i have a database with this in it:"

id	land	streek	rood	wit	rose
1	Frankrijk Bordeaux	1	1	0
2	Frankrijk Bourgogne	1	1	0
3	Frankrijk Rhône	        1	1	0
4	Frankrijk Provence	1	1	1
5	Frankrijk Loire	        1	1	0
6	Frankrijk Elzas	        1	1	1
7	Frankrijk Sud-Ouest	1	1	1
8	Frankrijk Languedoc-Rou	1	1	1
9	Frankrijk Vin de Pays	1	1	1
10	Frankrijk Champagne	0	1	1
11	Frankrijk Beaujolais	1	0	0

what i want to do is display all the items where the 4th value is 1, so there is one missing.
now i want to have them in lines of 5.
so this is my output:
Bordeaux Bourgogne Rhône Provence Loire
Elzas Sud-Ouest Languedoc-Roussilion Vin de Pays Beaujolais
Beaujolais

is it possible to get that Beaujolais only once?
(i know it should be possible:P)
for example just this:
Bordeaux Bourgogne Rhône Provence Loire
Elzas Sud-Ouest Languedoc-Roussilion Vin de Pays Beaujolais

this is the code i have so far:

<div id="streken">
	<table>
		<tr>
			<?php
			$query = "SELECT COUNT(*) from italie WHERE rood = 1";
			$result = mysql_query($query) or die('Error : ' . mysql_error());
			while(list($resultaat) = mysql_fetch_array($result, MYSQL_NUM))
			{
			echo $resultaat;
			}
			if ($resultaat < 6){
			$query = "SELECT id, streek FROM italie WHERE rood = 1 AND land = 'Italie' LIMIT 5";
			$result = mysql_query($query) or die('Error : ' . mysql_error());
			while(list($sid, $streek) = mysql_fetch_array($result, MYSQL_NUM))
			{
			?>
				<td id="strekenlijst">
					<a href="rood.php?id=<?php echo $id?>&sid=<?php echo $sid;?>"><?php echo $streek;?></a>
				</td>
			<?php }};?>
		</tr>
		<tr>
			<?php
			if ($resultaat < 11){
			$query = "SELECT streek FROM italie WHERE rood = 1 and id > 10  AND land = 'Italie'LIMIT 5";
			$result = mysql_query($query) or die('Error : ' . mysql_error());
			while(list($sid, $streek) = mysql_fetch_array($result, MYSQL_NUM))
			{
			?>
				<td id="strekenlijst">
					<a href="rood.php?id=<?php echo $id?>&sid=<?php echo $sid;?>"><?php echo $streek;?></a>
				</td>
			<?php }};?>
		</tr>
	</table>
</div>

Edited by thijscream: n/a

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by thijscream
0

Distinct ... I have a question for you and I really could use an honest answer. Why asking before searching at least 10 minutes? You spend match more time this way …. I am trying to understand in order to decide to answer or not in this kind of questions

0

Distinct ... I have a question for you and I really could use an honest answer. Why asking before searching at least 10 minutes? You spend match more time this way …. I am trying to understand in order to decide to answer or not in this kind of questions

maby i need to ask the question different,
how can i arrange the items by 5 per row. so you get number
1 2 3 4 5
6 7 8 9 11

instead of
1 2 3 4 5
6 7 8 9 11
11

0

Listen to the advice, use DISTINCT.

thanks for the advice but solved it in another way...

<div id="streken">
	<table>
		<tr>
			<?php
			$n = 0;
			$query = "SELECT id, streek FROM frankrijk WHERE rood = 1 AND land = 'Frankrijk'";
			$result = mysql_query($query) or die('Error : ' . mysql_error());
			while(list($sid, $streek) = mysql_fetch_array($result, MYSQL_NUM))
			{
			?>
				<td id="strekenlijst">
					<a href="rood.php?id=<?php echo $id?>&sid=<?php echo $sid;?>"><?php echo $streek;?></a>
				</td>
			<?php 
			$n++;
			if ($n % 5 == 0) echo '</tr><tr>';    
			}
			?>
		</tr>
	</table>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.