Besoin d'aide pour faire les en-têtes cliquables et triables
- frank_solo
- Born


- Inscription: Mar 09, 2011
- Messages: 1
- Status: Offline
Bonjour tout le monde c'est ma première fois, j'ai écrit un code à l'aide HTML_Table mais je voudrais les en-têtes sont cliquables afin que l'utilisateur peut faire le tri. Est-ce que quelqu'un sait comment cela peut être fait? Voici le code:
<?php
if ($_POST){
$county = $_POST['county'];
$rooms = $_POST['type'];
$rent = $_POST['rent'];
$rent_min = $rent - 500;
}
$dbase = mysql_connect ( ' ', ' ', ' ' );
mysql_select_db ( ' ', $dbase );
if($county){
$sql = "SELECT * FROM `apartments` WHERE `county` = '".$county."' AND `rooms` = '".$rooms."' AND `rent` < '".$rent."' AND `rent` > '".$rent_min."' ";
}else{
$sql = "SELECT * FROM `apartments`";
}
//include the class
require_once("/home/genesis/php/HTML/Table.php");
//set table attributes
$attributes = array("width"=>"600","border"=>"1", "align"=>"center");
//create the table class
$table = new HTML_Table($attributes);
//build our first row
$contents = array("County", "Town", "Phone Number", "Rooms", "Baths", "Rent");
$attributes = array("bgcolor"=>"#336699");
$table->addRow($contents, $attributes, "TH");
//loop through and add our data
$attributes = array("bgcolor"=>"#COCOCO");
$res = mysql_query($sql, $dbase);
while($row = mysql_fetch_assoc($res)) {
$contents = array($row['county'], $row['town'], $row['phone'], $row['rooms'], $row['bath'], $row['rent'],);
$table->addRow($contents, $attributes);
}
$table->altRowAttributes(1, null, array("class"=>"alt"));
$table->display();
?>
- <?php
- if ($_POST){
- $county = $_POST['county'];
- $rooms = $_POST['type'];
- $rent = $_POST['rent'];
- $rent_min = $rent - 500;
- }
-
- $dbase = mysql_connect ( ' ', ' ', ' ' );
- mysql_select_db ( ' ', $dbase );
-
- if($county){
- $sql = "SELECT * FROM `apartments` WHERE `county` = '".$county."' AND `rooms` = '".$rooms."' AND `rent` < '".$rent."' AND `rent` > '".$rent_min."' ";
- }else{
- $sql = "SELECT * FROM `apartments`";
- }
- //include the class
- require_once("/home/genesis/php/HTML/Table.php");
- //set table attributes
- $attributes = array("width"=>"600","border"=>"1", "align"=>"center");
- //create the table class
- $table = new HTML_Table($attributes);
- //build our first row
- $contents = array("County", "Town", "Phone Number", "Rooms", "Baths", "Rent");
- $attributes = array("bgcolor"=>"#336699");
- $table->addRow($contents, $attributes, "TH");
- //loop through and add our data
- $attributes = array("bgcolor"=>"#COCOCO");
- $res = mysql_query($sql, $dbase);
-
- while($row = mysql_fetch_assoc($res)) {
- $contents = array($row['county'], $row['town'], $row['phone'], $row['rooms'], $row['bath'], $row['rent'],);
- $table->addRow($contents, $attributes);
- }
- $table->altRowAttributes(1, null, array("class"=>"alt"));
- $table->display();
- ?>
Merci à tous d'avance
- Anonymous
- Bot


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Page 1 sur 1
Pour répondre à ce sujet, vous devez vous connecter ou vous enregistrer. Il est gratuit.
Afficher de l'information
- Total des messages de ce sujet: 1 message
- Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 242 invités
- Vous ne pouvez pas poster de nouveaux sujets
- Vous ne pouvez pas répondre aux sujets
- Vous ne pouvez pas éditer vos messages
- Vous ne pouvez pas supprimer vos messages
- Vous ne pouvez pas joindre des fichiers