TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-07-2005, 05:03 PM   #1 (permalink)
The Wanderer
 
Join Date: May 2005
Location: Maine|USA
Posts: 17
Thanks: 0
Ogden2k is on a distinguished road
Default Sort order problem

I have a little game database, I am trying to sort the data (per a user click) by title, or by systme or by whatever the user specifies. Here's the code that I have, it's not sorting:
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
    <title>Games Database</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> 
    <link rel="stylesheet" type="text/css" href="http://misc.techiehq.net/stuff/css/games.css" /> 
</head> 
<body> 
<div class="body_fore"> 

<div class="title">
Games:
</div> 

<table class="table_head"> 
<tr> 
     <td width="85">System <a href="index.php?order=system">^</a> v</td> 
     <td width="200">Title <a href="index.php?order=title">^</a> v</td> 
     <td width="110">Developer ^ v</td> 
     <td width="140">Publisher ^ v</td> 
     <td width="140">Year ^ v</td> 
     <td width="140">Purchased ^ v</td> 
     <td width="88">Genre ^ v</td> 
     <td width="120">Serial ^ v</td> 
</tr> 
</table>
 
<?php
// Connect to the DB server 
$dbcnx = @mysql_connect('localhost''x''x'); 
    if (!
$dbcnx) { 
    exit(
'<p>Unable to connect to the ' 
    
'database server at this time.</p>'); 

// Select the binarydr_stuff DB 
    
if (!@mysql_select_db('binarydr_stuff')) { 
    exit(
'<p>Unable to locate the stuff ' 
    
'database at this time.</p>'); 
}
// Request the text of all the info 
$result = @mysql_query('SELECT * FROM games'); 

if (!
$result) { 
    exit(
'<p>Error performing query: ' mysql_error() . '</p>'); 
}
// Display each game
while ($row mysql_fetch_array($result)) { 
echo 

<table class="cells"> 
<tr> 
     <td width="85">' 
$row['system'] . '</td> 
     <td width="200">' 
$row['title'] . '</td> 
     <td width="110">' 
$row['developer'] . '</td> 
     <td width="140">' 
$row['publisher'] . '</td> 
     <td width="140">' 
$row['year'] . '</td> 
     <td width="140">' 
$row['purchased'] . '</td> 
     <td width="88">' 
$row['genre'] .'</td> 
     <td width="120">' 
$row['serial'] .'</td> 
</tr> 
</table> 
'

}
$order = isset($_GET['order']) ? mysql_escape_string($_GET['order']) : 'system'// Request the text of all the info
    
$result1 = @mysql_query(
    
"SELECT system,title,developer,publisher, year,purchased,genre,serial FROM games 
    ORDER BY 
$order DESC"
);
// When clicked, this link will load this page with the hook sub form displayed 
echo '<div class="button_area"> 
<p>[ <a href="add.php">Add a Game</a> | <a href="../search/index.php">Search</a> | <a href="../">Home</a> | <a href="' 
$_SERVER['PHP_SELF'] . '">Refresh</a> ]</p></div> 
</div> 
</div>'
;
?> 
</body> 
</html>
__________________
TechieHQ
Send a message via AIM to Ogden2k
Ogden2k is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL problem Ogden2k Absolute Beginners 3 06-27-2005 10:06 PM
Welcome to talkPHP.com, please be sure to register in order to make full use of the hostingonline Feedback 3 04-15-2005 01:04 AM


All times are GMT. The time now is 02:12 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design