473,395 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

sorting multidimensional array

pradeepjain
563 512MB
Hii,
i need help in sorting multidimensianal array...

i Read the multi sort function cld not use tht so i need help..This is the code.
here the problem is tht i need to take out values from 2 different tables.i am getting the output properly but only thing is tht i need to sort the o/p as per name

here fid=6 is designation..uid is the id of the user ,fid=3 is Name of the person,fid=11 is for extension ,fid=1 is research interest,fid=2 is homepage,fid=7 is email,fid=8 for address,fid=9 for nick name,fid=12 | Thesis Title,fid= 13 | Supervisor ,fid=14 | Location ,fid= 17 | Room Number



[PHP]
<?php

print("<table width=100% border=1 bordercolor=white align=center cellspacing=1 cellpadding=1>");
print(" <tr bgcolor=#DEE2E6>");
print("<td><b>Name</b></td>");
print("<td><b>Email Id</b></td>");
print("<td><b>Room Number</b></td>");
print("<td><b>Extension</b></td>");
print(" </tr>");
$str_sql1="select min(uid) from profile_values where fid=13 and value =''";
$result=mysql_query($str_sql1);
$thisrow=mysql_fetch_row($result);
$a=$thisrow[0];
$str_sql2="select max(uid) from profile_values";
$result2=mysql_query($str_sql2);
$thisrow2=mysql_fetch_row($result2);
$b=$thisrow2[0];

$str_sql1="select distinct uid from profile_values";
$result=mysql_query($str_sql1);
$thisrow=mysql_fetch_row($result);
$a=4;
for($l = 0 ; $l <= $b ; $l++)
{
print(" <tr bgcolor=#DEE2E6>");
$str_sql5="select value from profile_values where uid=$l and fid=13";
$result5=mysql_query($str_sql5);
$thisroww=mysql_fetch_row($result5);
$str_sql2="select value from profile_values where uid=$l and fid=14";
$result1=mysql_query($str_sql2);
$thisrow1=mysql_fetch_row($result1);
if($thisrow1[0] == 'Bangalore' and $thisroww[0]==''){
$str_sql3="select value from profile_values where uid=$l and fid=11";
$result3=mysql_query($str_sql3);
$thisrow3=mysql_fetch_row($result3);

$str_sql7="select value from profile_values where uid=$l and fid=7";
$result7=mysql_query($str_sql7);
$thisrow7=mysql_fetch_row($result7);
$pos = strpos($thisrow7[0],'@');
$email = substr($thisrow7[0], 0, $pos);

$str_sql8="select value from profile_values where uid=$l and fid=17";
$result8=mysql_query($str_sql8);
$thisrow8=mysql_fetch_row($result8);



$str_sql="select * from profile_values where uid=$l and fid=3";
$res_id=mysql_query($str_sql);
$i=0;
$Colloquiums = array();
while($sub_row=mysql_fetch_array($res_id)){
$tmp = array(
'Count' => $i+1,
'fid' => $sub_row['fid'],
'uid' => $sub_row['uid'],
'value' => $sub_row['value']
);
$Colloquiums[$i++]= $tmp;
}
$lcount="$tmp[Count]";
$nj=$lcount-1;
print("<td>");
$ID=$Colloquiums[0][uid];
print("<a href='/user/$ID'>");
print_r($Colloquiums[0][value]);
print("</a>");
print("</td>");
if ($email != ""){
print("<td>");
echo $email;
print("</td>");
}else
{
print("<td>");
echo "-";
}
print("</td>");

print("<td>");
if($thisrow8[0]!=''){
echo $thisrow8[0];
}
else{
echo(" -");
}
print("</td>");
print("<td>");
if($thisrow3[0]!=''){
echo $thisrow3[0];
}
else{
echo(" -");
}
print("</td>");
}
print("</tr>");
}
?>[/PHP]
</table><br><br><br><br><br>


This is how profile_fields table structure looks

mysql> select * from profile_fields;
+-----+-------------------+---------------------+-------------+----------------------+------+-----------+--------+----------+----------+------------+--------------+---------+
| fid | title | name | explanation | category | page | type | weight | required | register | visibility | autocomplete | options |
+-----+-------------------+---------------------+-------------+----------------------+------+-----------+--------+----------+----------+------------+--------------+---------+
| 1 | Research Interest | profile_new | | Personal information | | textarea | -2 | 0 | 1 | 2 | 0 | |
| 2 | Homepage | profile_URL | | Personal information | | url | 5 | 0 | 1 | 2 | 0 | |
| 3 | Name | profile_Name | | Personal information | | textfield | -5 | 1 | 1 | 3 | 0 | |
| 7 | Email | profile_Email | | Personal information | | textfield | -3 | 0 | 1 | 2 | 0 | |
| 6 | Designation | profile_Designation | | Personal information | | textfield | -4 | 0 | 1 | 2 | 0 | |
| 11 | EXT | profile_EXT | | Personal information | | textfield | 0 | 0 | 1 | 2 | 0 | |
| 8 | Address | profile_Address | | Personal information | | textarea | -1 | 0 | 1 | 2 | 0 | |
| 9 | Nick | profile_Nick | | Personal information | | textfield | -5 | 0 | 1 | 2 | 0 | |
| 12 | Thesis Title | profile_Thesis | | Personal information | | textfield | -3 | 0 | 1 | 2 | 0 | |
| 13 | Supervisor | profile_Supervisor | | Personal information | | textfield | -2 | 0 | 1 | 2 | 0 | |
| 14 | Location | profile_Location | | Personal information | | textfield | 5 | 0 | 1 | 2 | 0 | |
| 15 | Staff | profile_Staff | | Personal information | | checkbox | 3 | 0 | 1 | 2 | 0 | |
| 16 | Student | profile_Student | | Personal information | | checkbox | 3 | 0 | 1 | 4 | 0 | |
| 17 | Room Number | profile_room | | Personal information | | textfield | 5 | 0 | 0 | 2 | 0 | |
+-----+-------------------+---------------------+-------------+----------------------+------+-----------+--------+----------+----------+------------+--------------+---------+
14 rows in set (0.01 sec)
Feb 20 '08 #1
1 1724
ronverdonk
4,258 Expert 4TB
I read your post a couple of times, but I don't comprehend the problem.

To put it another way: what makes your multi-dimensional table different from other multi-dimensional tables and what makes it impossible for you to use the standard PHP sort methods?

Ronald
Feb 22 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brian | last post by:
I have an array like this: $events = array( array( '2003-07-01', 'Event Title 1', '1' //ID Number (not unique) ), array( '2003-07-02',
2
by: markus | last post by:
I usually store info in arrays using field names $array='Germany', $array="GE"; $array='United Sates" $array="US"; $array='France" $array='FR"
2
by: MM | last post by:
Hi there, Is it at all possible to sort the contents of a table (ordinary html <table><tr><td>...</td></tr></table>) using javascript? What I want is to be able to select, for example by...
1
by: Gaspard Kayitare | last post by:
I would like to know how to use multidimensional arrays principles for sorting grades for four students obtained in four subjects.I am supposed to arrange the data in a form of a table,students...
6
by: Index | last post by:
Hi, I have a 4 dimensional array and I want to sort it by the first two columns emulating an ORDER BY clause to some extent.Any suggestion? The original Array is: Row1-> 4 8 2 9 Row2-> 4 5 5...
9
by: Dylan Parry | last post by:
Hi folks, I have a database that contains records with IDs like "H1, H2, H3, ..., Hn" and these refer to local government policy numbers. For example, H1 might be "Housing Policy 1" and so on....
16
by: Rehceb Rotkiv | last post by:
Hello everyone, can I sort a multidimensional array in Python by multiple sort keys? A litte code sample would be nice! Thx, Rehceb
7
pradeepjain
by: pradeepjain | last post by:
Hello Guys, I am using a multidimensional array in which there is a date field also..i want to sort the multidimensional array based on this date filed how to do this. ...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.