I want to sort the following table, that contains this data, in a .php page I'll use on my website.
I want to sort it by a few columns too, I want it to sort by points, then difference, then for.
The following is the code I have in my .php file. - <? $hostname = "***.secureserver.net"; // The mySQL DB server.
-
$username = "acssl_table"; // The username you created for this database.
-
$password = "Victoria3"; // The password you created for the username.
-
$usertable = "table"; // The name of the table you made.
-
$dbName = "acssl_table"; // This is the name of the database you made.
-
-
MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
-
@mysql_select_db( "$dbName") or die( "Unable to select database");
-
?>
-
<?
-
//error message (not found message)begins
-
$XX = "No Record Found, to search again please close this window";
-
//query details table begins
-
$query = mysql_query("SELECT * FROM `table` LIMIT 0, 30 ");
-
while ($row = @mysql_fetch_array($query))
-
{
-
$variable1=$row["team"];
-
$variable2=$row["played"];
-
$variable3=$row["won"];
-
$variable4=$row["drawn"];
-
$variable5=$row["lost"];
-
$variable6=$row["for"];
-
$variable7=$row["against"];
-
$variable8=$row["difference"];
-
$variable9=$row["points"];
-
//table layout for results
-
-
print ("<tr>");
-
print ("<td width='150'><span class='BodyTable'>$variable1</span></td>");
-
print ("<td width='50' align='center'><span class='BodyTable'>$variable2</span></td>");
-
print ("<td width='50' align='center'><span class='BodyTable'>$variable3</span></td>");
-
print ("<td width='50' align='center'><span class='BodyTable'>$variable4</span></td>");
-
print ("<td width='50' align='center'><span class='BodyTable'>$variable5</span></td>");
-
print ("<td width='50' align='center'><span class='BodyTable'>$variable6</span></td>");
-
print ("<td width='50' align='center'><span class='BodyTable'>$variable7</span></td>");
-
print ("<td width='75' align='center'><span class='BodyTable'>$variable8</span></td>");
-
print ("<td width='75' align='center'><span class='BodyTable'>$variable9</span></td>");
-
print ("</tr>");
-
}
-
//below this is the function for no record!!
-
if (!$variable1)
-
{
-
print ("$XX");
-
}
-
//end
-
?>
4 1617 Motoma 3,237
Recognized Expert Specialist
The images did not work for me.
I would suggest, however, that you use a simple ORDER BY clause when doing your SELECT: -
$query = mysql_query("SELECT * FROM `table` ORDER BY points DESC, difference ASC, for ASC LIMIT 0, 30 ");
-
thanks, but that doesn't completely work..
it'll only let me sort it by the Points and Difference. Whenever I try to sort using for, the entire table crashes.
why?
Even if I'm sorting by For on its own, it crashes the table.
heres another screenshot of the data, hopefully this one will work.
but i doubt the problem is in the actual database
thanks, but that doesn't completely work..
it'll only let me sort it by the Points and Difference. Whenever I try to sort using for, the entire table crashes.
why?
Even if I'm sorting by For on its own, it crashes the table.
Of course it sorts by Point and Difference only. That is what has been specified in the SELECT statement. For other columns, you just have to change the SELECT statement's ORDER BY sequence to get another order for other column(s).
So, when you want to sort on 'For' you issue the statement - $query = mysql_query("SELECT * FROM `table` ORDER BY for ASC LIMIT 0, 30 ");
Ronald :cool:
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: somaBoy MX |
last post by:
This may be a stupid question, but what is the easiest way to sort a mysql
resultset?
For example I have a resulset containing a colomn 'product_name_english' and
'product_name_french' and want to sort the result on one of these colums
based on a language parameter.
I know how to do this in a query ("ORDER BY") but how can I do this after
the query has been executed?
|
by: Phil Powell |
last post by:
Very simplistic but I am utterly STUMPED at this one.
I have a db table "person" that I can sort by title, first_name,
last_name, or city with no problems at all because "title",
"first_name", "last_name", and "city" are columns in the table.
The requirement is to ALSO sort by department NAME. Problem is, I
can't do that in the "person" table because the column is
"department_id" which is a foreign key constraint to the department...
|
by: anders thoresson |
last post by:
Is it possible to resort the rows in a table like in a query where using
ORDER BY, but have to new sort order stored in the table structure?
--
anders thoresson
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=mysql@freebsd.csie.nctu.edu.tw
|
by: yellow1912 |
last post by:
Ok, lets say I have 1000 items in my database (mysql) and want to
display X items per page. I learned to do it by querying with the LIMIT
constrain (something like this
http://www.snipe.net/content/view/12/35/). The problem is I cant sort
using this algorithm (or maybe I just dont know how to do it). ORDER BY
didnt do the trick for me :(.
The only way I can think of is to pass all the item keys/names/anything
I want to sort into an array,...
|
by: phillip.s.powell |
last post by:
Ok, you have three tables. You're supposed to be able to not only sort
(ORDER BY) according to a_name, no problem, but you must also have the
ability to sort (ORDER BY) the relationship between table_a and
table_b, that is, say you have this:
Here is where the problem lies. I am required to be able to sort by
'Phil', no problem:
| |
by: news reader |
last post by:
Hi,
Does anoone of you know if there is already a simple application doing
something like this.
I would enhance / tune the missing features, but would like to avoid to
start from scratch or to start from something, that has far too many
features and is difficult to setup.
|
by: weetat.yeo |
last post by:
Hi all ,
I have sql statement below ,
SELECT
serial_no,host_name,chasis_model,chasis_flash_size,chasis_dram_size,
country,city,building,other,chasis_sw_version,status,chasis_eos,chasis_eol,chasis_user_field_1,chasis_user_field_2,chasis_user_field_3
FROM tbl_chassis ORDER BY country = '', country
|
by: Vic Spainhower |
last post by:
Hello,
I have an HTML table that is being constructed from a MySQL table and
displays a form that includes a check box on 1 of the fields on the form for
each record. I have included in this PHP program a javascript routine called
sorttable.js which is something I found on the internet for sorting tables
and works quite well. The HTML table includes a check box on each record so
the user can select certain records for passing to the...
|
by: mfaisalwarraich |
last post by:
Hi Everybody,
I am using the following function to get the data from mysql database. i have entered appnum field as text filed in the database which has leading zeroes to this field like if number is 0001, 0010, 0101 (four figures). Now i got problem while sorting them as it is a string value and its giving error when im trying to convert it into integer using (int)$appnum its trimming the leading zeros. I want this field as the string field...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |