Big Problem - mysql_query
Ik heb een probleem waar jullie mij vast mee kunnen helpen. Op de link hieronder staat het resultaat. Zoals je ziet worden 3 limousines 6 keer getoond. Dit moet 1 keer zijn. Wie kan mij helpen? Alvast bedankt.
http://i31.tinypic.com/qx7614.jpg
CODE
--------------------------------
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
$dbhost = 'localhost';
$dbusername = '*';
$dbuserpassword = '*';
$default_dbname = '*';
$db = mysql_connect($dbhost,$dbusername,$dbuserpassword);
mysql_select_db("***", $db);
/*** Menu weergaven ***/
$query = mysql_query("
SELECT *
FROM menu
WHERE parent_menuID = '1' AND active = '1'
ORDER by seq
",$db);
echo mysql_error();
?>
$dbhost = 'localhost';
$dbusername = '*';
$dbuserpassword = '*';
$default_dbname = '*';
$db = mysql_connect($dbhost,$dbusername,$dbuserpassword);
mysql_select_db("***", $db);
/*** Menu weergaven ***/
$query = mysql_query("
SELECT *
FROM menu
WHERE parent_menuID = '1' AND active = '1'
ORDER by seq
",$db);
echo mysql_error();
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
// start
while($row = mysql_fetch_assoc($query)){
// start 2
$query2 = mysql_query("
SELECT *
FROM menu
WHERE parent_menuID = '102' AND active = '1' AND verwijderd = '0'
ORDER by seq
",$db);
echo mysql_error();
while($row1 = mysql_fetch_array($query2)){
echo '<li><a href="#" title="'.$row1['menu_name'].'">'.$row1['menu_name'].'</a>' ;
echo '</li>';
}
//einde 2
$menu_name_clean = $row['menu_name'];
$menu_name_clean=str_replace("&","_",$menu_name_clean);
$menu_name_clean=str_replace(" ","_",$menu_name_clean);
$menu_name_clean = stripslashes($menu_name_clean);
$site_menu = "
<li>
<a href=\"?page=".$menu_name_clean."&menuID=".($query2['menuID'])."&pageID=".($query2['pageID'])."\">
".stripslashes($row['menu_name']).' - '.$row['menuID']."
</a>
</li>\n";
echo $site_menu;
}
//echo $site_menu;
?>
// start
while($row = mysql_fetch_assoc($query)){
// start 2
$query2 = mysql_query("
SELECT *
FROM menu
WHERE parent_menuID = '102' AND active = '1' AND verwijderd = '0'
ORDER by seq
",$db);
echo mysql_error();
while($row1 = mysql_fetch_array($query2)){
echo '<li><a href="#" title="'.$row1['menu_name'].'">'.$row1['menu_name'].'</a>' ;
echo '</li>';
}
//einde 2
$menu_name_clean = $row['menu_name'];
$menu_name_clean=str_replace("&","_",$menu_name_clean);
$menu_name_clean=str_replace(" ","_",$menu_name_clean);
$menu_name_clean = stripslashes($menu_name_clean);
$site_menu = "
<li>
<a href=\"?page=".$menu_name_clean."&menuID=".($query2['menuID'])."&pageID=".($query2['pageID'])."\">
".stripslashes($row['menu_name']).' - '.$row['menuID']."
</a>
</li>\n";
echo $site_menu;
}
//echo $site_menu;
?>
Gewijzigd op 01/01/1970 01:00:00 door Roy Dekker
Op je eerste screen laat je niet alle relevantie code zien. Je kan je code gewoon posten in een reactie hier. Even tussen de PHP openings- en sluittag zetten en alles gaat goed.
Aangepast:) Sorry ben hier net nieuw
Wat is de inhoud van je DB ?
voer deel 2 6x uit (je heb 6 rijen bij de eerste query)
Als je snap wat ik bedoel
Gelieve Niet Bumpen::
Moet ik deel 2 dan 6 x uitvoeren?? Sorry maar begrijp niet helemaal wat je bedoel.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$dbhost = 'localhost';
$dbusername = '*';
$dbuserpassword = '*';
$default_dbname = '*';
$db = mysql_connect($dbhost,$dbusername,$dbuserpassword);
mysql_select_db("***", $db);
/*** Menu weergaven ***/
$query = mysql_query("
SELECT *
FROM menu
WHERE parent_menuID = '1' AND active = '1'
ORDER by seq
",$db); < hier selecteer je je eerste DB
echo mysql_error();
?>
$dbhost = 'localhost';
$dbusername = '*';
$dbuserpassword = '*';
$default_dbname = '*';
$db = mysql_connect($dbhost,$dbusername,$dbuserpassword);
mysql_select_db("***", $db);
/*** Menu weergaven ***/
$query = mysql_query("
SELECT *
FROM menu
WHERE parent_menuID = '1' AND active = '1'
ORDER by seq
",$db); < hier selecteer je je eerste DB
echo mysql_error();
?>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
// start
while($row = mysql_fetch_assoc($query)){ <hier zet je hem in een loop deze wordt 6 keer uitgevoerd omdat er 6 menukopjes zijn.
// start 2
$query2 = mysql_query(" <hier selecteer je DB 2
SELECT *
FROM menu
WHERE parent_menuID = '102' AND active = '1' AND verwijderd = '0'
ORDER by seq
",$db);
echo mysql_error();
while($row1 = mysql_fetch_array($query2)){
echo '<li><a href="#" title="'.$row1['menu_name'].'">'.$row1['menu_name'].'</a>' ;
echo '</li>';
}
//einde 2
$menu_name_clean = $row['menu_name'];
$menu_name_clean=str_replace("&","_",$menu_name_clean);
$menu_name_clean=str_replace(" ","_",$menu_name_clean);
$menu_name_clean = stripslashes($menu_name_clean);
$site_menu = "
<li>
<a href=\"?page=".$menu_name_clean."&menuID=".($query2['menuID'])."&pageID=".($query2['pageID'])."\">
".stripslashes($row['menu_name']).' - '.$row['menuID']."
</a>
</li>\n";
echo $site_menu;
}
//echo $site_menu;
?>
// start
while($row = mysql_fetch_assoc($query)){ <hier zet je hem in een loop deze wordt 6 keer uitgevoerd omdat er 6 menukopjes zijn.
// start 2
$query2 = mysql_query(" <hier selecteer je DB 2
SELECT *
FROM menu
WHERE parent_menuID = '102' AND active = '1' AND verwijderd = '0'
ORDER by seq
",$db);
echo mysql_error();
while($row1 = mysql_fetch_array($query2)){
echo '<li><a href="#" title="'.$row1['menu_name'].'">'.$row1['menu_name'].'</a>' ;
echo '</li>';
}
//einde 2
$menu_name_clean = $row['menu_name'];
$menu_name_clean=str_replace("&","_",$menu_name_clean);
$menu_name_clean=str_replace(" ","_",$menu_name_clean);
$menu_name_clean = stripslashes($menu_name_clean);
$site_menu = "
<li>
<a href=\"?page=".$menu_name_clean."&menuID=".($query2['menuID'])."&pageID=".($query2['pageID'])."\">
".stripslashes($row['menu_name']).' - '.$row['menuID']."
</a>
</li>\n";
echo $site_menu;
}
//echo $site_menu;
?>
Nu wel duidelijk ?
die de < [t e k s t ]
Ja ik snap wat je bedoeld. Alleen het maken vn een oplossing is vrij ingewikkeld:p Ben nog geen prof