login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Alles in een pagina (Opgelost)

Offline Desinger - 24/08/2008 22:30 (laatste wijziging 24/08/2008 22:31)
Avatar van DesingerNieuw lid Momenteel ben ik bezig met een categorie systeem. Nu vraag ik mij af of het mogelijk is alles in éé pagina te open. Voorlopig heb ik zo opgelost:

Hoofdgroeptabel:
http://www.medi...ptabel.JPG

Subgroeptabel:
http://www.medionowners.be/meuk/subgroeptabel.JPG

infotabel:
http://www.medionowners.be/meuk/infotabel.JPG

index1:
  1. <?php
  2. include_once 'configuratie.php';
  3.  
  4.  
  5.  
  6. $sql = "SELECT `id`,`naam` FROM hoofdgroeptabel ";
  7. //-- via de functie mysql_query() kun je de SQL code
  8. //-- die in $sql staat uitvoeren.
  9. $res = mysql_query($sql) or die(mysql_error());
  10.  
  11.  
  12.  
  13.  
  14. ?>
  15.  
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title></title>
  21. </head>
  22.  
  23. <body>
  24. Link: <br /><br />
  25. <?php
  26. while( $row = mysql_fetch_array( $res ) ) {
  27.  
  28. echo " <a href=\"index1.php?id=" . $row['id'] . "\">" . htmlentities($row['naam']) . "</a><br>";
  29.  
  30. }
  31. ?>
  32.  
  33.  
  34. </body>
  35. </html>


index1.php:

  1. <?php
  2. include_once 'configuratie.php';
  3.  
  4. $id = mysql_real_escape_string($_GET['id']);
  5.  
  6. $sql = "SELECT `hoofdgroeptabelid`,`naam`, `id` FROM subgroeptabel WHERE `hoofdgroeptabelid` = '$id'";
  7. //-- via de functie mysql_query() kun je de SQL code
  8. //-- die in $sql staat uitvoeren.
  9. $res = mysql_query($sql) or die(mysql_error());
  10.  
  11.  
  12.  
  13.  
  14. ?>
  15.  
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title></title>
  21. </head>
  22.  
  23. <body>
  24. Link: <br /><br />
  25. <?php
  26. while( $row = mysql_fetch_array( $res ) ) {
  27.  
  28. echo " <a href=\"index2.php?id=" . $row['id'] . "\">" . htmlentities($row['naam']) . "</a><br>";
  29.  
  30. }
  31. ?>
  32.  
  33.  
  34. </body>
  35. </html>


index2.php:
  1. <?php
  2. include_once 'configuratie.php';
  3.  
  4. $id = mysql_real_escape_string($_GET['id']);
  5.  
  6. $sql = "SELECT `subgroeptabelid` ,`tip`,`id`,`titel`,`date` FROM infotabel WHERE `subgroeptabelid` = '$id'";
  7. //-- via de functie mysql_query() kun je de SQL code
  8. //-- die in $sql staat uitvoeren.
  9. $res = mysql_query($sql) or die(mysql_error());
  10.  
  11.  
  12.  
  13.  
  14. ?>
  15.  
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title></title>
  21. </head>
  22.  
  23. <body>
  24. Link: <br /><br />
  25. <?php
  26. while( $row = mysql_fetch_array( $res ) ) {
  27.  
  28. echo " <a href=\"index3.php?id=" . $row['id'] . "\">" . htmlentities($row['titel']) . "</a><br>";
  29.  
  30. }
  31. ?>
  32.  
  33.  
  34. </body>
  35. </html>


index3.php:

  1. <?php
  2. include_once 'configuratie.php';
  3.  
  4. $id = mysql_real_escape_string($_GET['id']);
  5.  
  6. $sql = "SELECT `subgroeptabelid` ,`tip`,`id`,`titel`,`date` FROM infotabel WHERE `id` = '$id'";
  7. //-- via de functie mysql_query() kun je de SQL code
  8. //-- die in $sql staat uitvoeren.
  9. $res = mysql_query($sql) or die(mysql_error());
  10.  
  11.  
  12.  
  13.  
  14. ?>
  15.  
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title></title>
  21. </head>
  22.  
  23. <body>
  24. <br /><br />
  25. <?php
  26. $row = mysql_fetch_array( $res );
  27.  
  28. $row['tip'] = nl2br($row['tip']);
  29.  
  30. echo $row['tip'];
  31.  
  32.  
  33. ?>
  34.  
  35.  
  36. </body>
  37. </html>

2 antwoorden

Gesponsorde links
Offline Stijn - 24/08/2008 22:56
Avatar van Stijn PHP expert
  1. SELECT * FROM info INNER JOIN subgroeptabel s INNER JOIN hoofdgroeptabel h ON( info.subgroeptabelid = s.id AND s.hoofdgroeptabelid = h.id)
Voer die eens uit in je phpmyadmin en wees niet bang om de foutjes die eventueel gegeven worden zelf op te lossen.

http://www.site...ySQL/Joins , dat is ook nog een handige tutorial.
Offline Desinger - 24/08/2008 23:23 (laatste wijziging 24/08/2008 23:25)
Avatar van Desinger Nieuw lid Heb deze : SELECT * FROM infotabel INNER JOIN subgroeptabel s INNER JOIN hoofdgroeptabel h ON( infotabel.subgroeptabelid = s.id AND s.hoofdgroeptabelid = h.id) in mijn index.php gezet

index.php:
  1. <?php
  2. include_once 'configuratie.php';
  3.  
  4.  
  5.  
  6. $sql = "SELECT * FROM infotabel INNER JOIN subgroeptabel s INNER JOIN hoofdgroeptabel h ON( infotabel.subgroeptabelid = s.id AND s.hoofdgroeptabelid = h.id)";
  7. //-- via de functie mysql_query() kun je de SQL code
  8. //-- die in $sql staat uitvoeren.
  9. $res = mysql_query($sql) or die(mysql_error());
  10.  
  11.  
  12.  
  13.  
  14. ?>
  15.  
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  20. <title></title>
  21. </head>
  22.  
  23. <body>
  24. Link: <br /><br />
  25. <?php
  26. while( $row = mysql_fetch_array( $res ) ) {
  27.  
  28. echo " <a href=\"index1.php?id=" . $row['id'] . "\">" . htmlentities($row['naam']) . "</a><br>";
  29.  
  30. }
  31. ?>
  32.  
  33.  
  34. </body>
  35. <
/html>


krijg ik nu 4 keer windows onder elkaar te zien, dit moet
windows
office
internet
hardware worden
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.222s