Toon posts:

PHP Sort by.... icm navigatie

Pagina: 1
Acties:
  • 27 views sinds 30-01-2008

Verwijderd

Topicstarter
<TABLE WIDTH="745" border="0" cellSpacing=0 cellPadding=0 marginHeight>

<?PHP

mysql_connect("$host","$user","$pass");
mysql_select_db("$database");


$perpagina = 15; // aantal records per pagina
$q = mysql_query("Select * From cars where cat='Clubs' ");
$aantal = mysql_num_rows($q);

$p = (isset($_GET['p'])) ? $_GET['p'] - 1 : 0;

$begin = $perpagina * $p;

$aantalpagina = ceil($aantal / $perpagina);

$Back = ($p == 0) ? '« Back' : '<a href='.$_SERVER['PHP_SELF'].'?p='.$p.'>« Back</a>';
$Next = (($p + 1) == $aantalpagina) ? 'Next »' : '<a href='.$_SERVER['PHP_SELF'].'?p='.($p + 2).'>Next »</a>';

$i = 1;
for($i = 1; $i <= $aantalpagina; $i++) {
$paginas .= ($i == ($p +1)) ? ' '.$i .' |' : ' <a href='.$_SERVER['PHP_SELF'].'?p='.$i.'>'.$i.'</a> |';
}

$nav = $Back .' | '. $paginas .' '. $Next.'';

// deze query ook aanpassen.. behalve het Limit gebeuren:
$query = mysql_query("Select * From cars where cat='Clubs'Limit $begin,$perpagina");


?>

<?php


$sql = "SELECT distinct * FROM cars where cat='Clubs' Limit $begin,$perpagina" ; // Dit is de query

if ($action == 'name') {
$sql="SELECT * FROM cars where cat='Clubs' ORDER BY 'name' Limit $begin,$perpagina";
}
if ($action == 'description') {
$sql="SELECT * FROM cars where cat='Clubs' ORDER BY 'description' Limit $begin,$perpagina";
}
if ($action == 'cars_type') {
$sql="SELECT * FROM cars where cat='Clubs' ORDER BY 'cars_type' Limit $begin,$perpagina";
}


// connects to database
mysql_connect("$host","$user","$pass");

// selects database
mysql_select_db("$database");


$resultaat=mysql_query($sql);
$aantal=mysql_num_rows($resultaat);
echo " \n";

echo "


<TD Class=fcellmainmenu WIDTH=\"30%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=left WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\">Displaying $aantal cars Clubs sites </FONT>
</TD></TABLE></TD>

<TD Class=fcellmainmenu WIDTH=\"35%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=right WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\"><B>Other cars categories:</B></FONT>
</TD></TABLE></TD>

<TD Class=fcellmainmenu WIDTH=\"10%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=right WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\">»  <A href=link_cars_info.php>Info</a></FONT>
</TD></TABLE></TD>

<TD Class=fcellmainmenu WIDTH=\"10%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=right WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\">»  <A href=link_cars_parts.php>Parts</a></FONT>
</TD></TABLE></TD>


<TD Class=fcellmainmenu WIDTH=\"10%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD Class=fcellmainmenu align=right WIDTH=\"100%\">»  <A href=link_cars_specials.php>Specials</a>
</TD></TABLE></TD>
</TR></TABLE>


<BR>


<TABLE WIDTH=\"745\" border=\"0\" cellSpacing=0 cellPadding=0>

<TR HEIGHT=\"35\">
<TD Class=fcelltest WIDTH=\"30%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=left WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\">»  <B><a href=link_cars_clubs.php?action=name>Name</a></B></FONT>
</TD></TABLE></TD>


<TD Class=fcelltest WIDTH=\"40%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=left WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\">»  <B><a href=link_cars_clubs.php?action=description>Description</a></B></FONT>
</TD></TABLE></TD>

<TD Class=fcelltest WIDTH=\"15%\">
<TABLE width=100% border=0 cellspacing=2 cellpadding=2>
<TD align=left WIDTH=\"100%\"><font size=\"-2\" face=\"Verdana, Arial, Helvetica, sans-serif\" COLOR=\"#FFFFFF\">»  <B><A href=link_cars_clubs.php?action=cars_type>Type</a></B></FONT>
</TD></TABLE></TD>

</TR>\n";

while ($record=mysql_fetch_object($resultaat)) {

echo "<TR HEIGHT=\"25\">

<TD Class=fcelllinkleft><a href=\"$record->url\" target=\"_new\" nd();return s('')\">$record->name</a></TD>
<TD Class=fcelllinkmiddle>$record->description </TD>
<TD Class=fcelllinkright>$record->cars_type </TD></TR>\n";

}

echo "</TABLE><BR><BR>";
echo $nav;

?>
</TD>
</TR>

<BR><BR><BR><BR>
<TABLE width=745 border=0 cellspacing=0 cellpadding=0>
<TR>
<TD>
<H2>SPONSERED LINKS</H2></TD>
</TR>


</TABLE>

</CENTER>
</BODY>
</HTML>


-------

De basis van deze pagina werkt tot alle tevredenheid op één ding na;

Bezoeker bekijkt bv. de tweede pagina:
[http://localhost:8000/link_car_clubs.php?p=2]

maar hij wil nu sorten op "Name"; hier komt ie uit:
[http://localhost:8000/2links/link_car_clubs.php?action=name]

Vanzelfsprekend gekeken naar de link die erbij hoort:

<a href=link_cars_clubs.php?action=description>Description</a></B></FONT>
</TD></TABLE></TD>


Wat moet ik aanpassen om er voor te zorgen dat hij de data sorteert die behoort tot de pagina waarin bezoeker staat?

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

Geen touw aan vast te knopen..... lees P&W FAQ - De "quickstart" eens heel goed door en probeer het aan de hand van die tips eens met een nieuw topic, met minder code, meer tekst en [code]-tags enzo :)

Professionele website nodig?


  • flashin
  • Registratie: Augustus 2002
  • Laatst online: 17-12-2023
is niet echt duidelijk zo.. ook deze link zal nooit werken hier :P :
http://localhost:8000/2links/link_car_clubs.php?action=name

localhost :P

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

Ieps ik had deze dus op slot bedoeld :P

Dennis1977 mag een geheel nieuw topic brouwen, maar dan wel leesbaar :D

Professionele website nodig?


Dit topic is gesloten.