Jump to content
php.lv forumi

[Atrisināts] Order BY


xmas12

Recommended Posts

Sveiki, man izvelk no tabulas konkursa uzvaretajus, piemeram no lielaka uz mazako skaitli, un ar limit 5, bet daziem ir taja konkursa 13 skaitlis, bet vins to neizvelk, bet citiem to skaitli izvelk..

 

Kods:

 

<?php


$result = mysql_query("SELECT * FROM users ORDER BY konkurss DESC limit 5");

while($row = mysql_fetch_array($result))
 {
 echo '<tr>
	<td align="center" bgcolor="#2E2E2E">#</td>
	<td align="left" valign = "top" bgcolor="#2E2E2E"><b>' . $row['username'] . '<a></b></td>
	<td bgcolor="#2E2E2E">' . $row['konkurss'] . '</td></tr>';
 }
 			echo '</td></tr>
</table>';
?>

 

Kpc viņš neizvelk tos skaitļus ?

Edited by xmas12
Link to comment
Share on other sites

Kopā ar limit jānorāda sākot ar kuru ierakstu un cik lielā skaitā ierakstus izvilkt. Lai dabūtu pirmos 5 ierakstus būtu šitādi:

$result = mysql_query("SELECT * FROM users ORDER BY konkurss DESC limit 0,5");

tapat neiet, kr4 man izvelk tikai dazus userus kuri ir topa. piemeram tam kuram ir 13 cipars ieks datubazes, to neizvelk, bet kuram ir 8 vai citi, tos izvelk ... kpc ta ?

Link to comment
Share on other sites

CREATE TABLE IF NOT EXISTS `tb_users` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `username` varchar(15) COLLATE latin1_general_ci NOT NULL,
 `password` varchar(100) COLLATE latin1_general_ci NOT NULL,
 `ip` varchar(15) COLLATE latin1_general_ci NOT NULL,
 `email` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `pemail` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `referer` varchar(15) COLLATE latin1_general_ci NOT NULL,
 `country` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `visits` varchar(150) COLLATE latin1_general_ci NOT NULL DEFAULT '0',
 `referals` varchar(150) COLLATE latin1_general_ci NOT NULL DEFAULT '0',
 `referalvisits` varchar(150) COLLATE latin1_general_ci NOT NULL DEFAULT '0',
 `money` varchar(150) COLLATE latin1_general_ci NOT NULL DEFAULT '0.00',
 `paid` varchar(150) COLLATE latin1_general_ci NOT NULL DEFAULT '0.00',
 `joindate` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `lastlogdate` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `lastiplog` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `account` varchar(150) COLLATE latin1_general_ci NOT NULL,
 `user_status` varchar(15) COLLATE latin1_general_ci NOT NULL DEFAULT 'user',
 `piesaistes_konkurss` varchar(100) COLLATE latin1_general_ci NOT NULL DEFAULT '0',
 KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=256 ;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...