RE: [PHP] mySQL function
| From: | Christensen, BruceX R | Date: | Thu, 10 Aug 2000 02:24:26 +0000 |
| Subject: | RE: [PHP] mySQL function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-11029@lists.php.net to get a copy of this message | ||
Oops! I put the DESC before the field name. It should have been after, as
in
$result = mysql_query("SELECT * FROM $dbname ORDER BY points, team
DESC",$db);
Sorry 'bout that!
--Bruce
Bruce Christensen
Intel Corporation
brucex.r.christensen@intel.com
-----Original Message-----
From: Craig Henderson [mailto:craigh@mail.ocis.net]
Sent: Wednesday, August 09, 2000 7:06 PM
To: Christensen, BruceX R
Subject: RE: [PHP] mySQL function
Hey Bruce, thanks for the reply, I really appreciate it, however I can't
seem to get it to work (I am probably doing something wrong) here is what I
have:
$db = mysql_connect("localhost", "username", "password");
mysql_select_db("virtualw2",$db);
$result = mysql_query("SELECT * FROM $dbname ORDER BY points, DESC
team",$db);
if ($myrow = mysql_fetch_array($result))
and I am getting this error message:
Warning: 0 is not a MySQL result index in
/opt2/virtualw2/httpd/htdocs/thesportsbarn/statsadmin/viewteam.php3 on line
25
If you have any suggestions I would really appreciate it!!
Thanks!
--Craig Henderson SAE, Adgrafix Corporation
-----Original Message-----
From: Christensen, BruceX R [mailto:brucex.r.christensen@intel.com]
Sent: Wednesday, August 09, 2000 6:47 PM
To: 'Craig Henderson'; php-general@lists.php.net
Subject: RE: [PHP] mySQL function
The records stored in a database are designed to be order-independent, so
it's not possible to change the order that they appear in the database
(physically). Instead, you specify how you want them sorted when you
retrieve them from the database using a query such as:
SELECT name, address, phone
FROM customers
ORDER BY name, DESC address
This query gets the name, address, and phone number of all customers listed
in the database table named "customers"; furthermore, it returns those
records sorted alphanumerically (actually by ASCII character code) by name,
and if two addresses are the same, it sorts in reverse order by the address.
For more information on SQL, check the Yahoo SQL club's links page.
--Bruce
Bruce Christensen
Intel Corporation
brucex.r.christensen@intel.com
-----Original Message-----
From: Craig Henderson [mailto:craigh@mail.ocis.net]
Sent: Wednesday, August 09, 2000 6:37 PM
To: php-general@lists.php.net
Subject: [PHP] mySQL function
Hey, I have a mySQL database that I am adding entries to via an online form.
What I want to do is sort the mySQL table each time a new entry is added.
So, since I'm not that familiar with mySQL (I haven't had time to learn it
yet) does anyone know of a PHP function that I can call to sort my database?
(I checked the online PHP manual and didn't see anything) Thanks in advance.
--Craig Henderson SAE, Adgrafix Corporation
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net