473,387 Members | 1,899 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,387 software developers and data experts.

displaying distinct rows

Hello,

How do you display distinct fields when a query returns an array ??

This is the current output of my query:

PF0001 WB1 D1-drd-N1
PF0001 WB1 D1-drd-N2
PF0001 WB1 D1-drd-N3

and I want it to display like this:

PF0001 WB1 D1-drd-N1
D1-drd-N2
D1-drd-N3
this is the result of 1 query..so i display it using mysql_fetch_array
but i dont know how to display it the way i want it..the redundant first two fields should display only once.
Anybody who could help me??
Jan 4 '07 #1
2 1598
ronverdonk
4,258 Expert 4TB
I don't know your output layout, but something like the following[php]// Assuming $row['field1'] and $row['field2'] contain header info
// and $row['field3'] the detail info
$save_fields="";
while ($row=mysql_fetch_array(your_object)) {
$hdr_fields = $row['field1'].$row['field2'];
if ($hdr_fields != $save_fields) {
$save_fields = $hdr_fields;
echo $row['field1']." ".$row['field2'];
}
echo $row['field3'];
}[/php]
Ronald :cool:
Jan 4 '07 #2
[php]

//query execution
$count=mysql_num_rows($query);
for($i=0;$i<$count;$i++)
{
$get_resutl=mysql_fetch_array($query)

$filed1=$get_resutl['filed_name1'];
$filed2=$get_resutl['filed_name2'];
$filed3=$get_resutl['filed_name3'];

if($i==0)
{
echo $filed1;
}

echo $filed2;
echo $filed3
echo "<br>";
}
[/php]
Jan 4 '07 #3

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

Similar topics

5
by: Ralph Freshour | last post by:
I have a question about the following PHP script - I got it off a web site tutorial on how to count users logged into your site - my question is the $PHP_SELF variable - it writes the name of the...
2
by: middletree | last post by:
I tried posting this to the SQL Server programming group, but then thought more about it, and thought it was more of an ASP question. If you want the original long description, it's below. But the...
4
by: Johnson, Shaunn | last post by:
Howdy: Can someone tell what the difference (and why you would use it) is between the following: select distinct on (col_1, col_2), col_1, col_2, col_3
1
by: Alex Satrapa | last post by:
I have a table from which I'm trying to extract certain information. For historical reasons, we archive every action on a particular thing ('thing' is identified, funnily enough, by 'id'). So the...
2
by: Michael Howes | last post by:
I have a single DataTable in a DataSet. It has 4 columns and i'd like to get a handful of counts of unique items in 3 of the 4 columns. Can a DataTables Select or Compute methods to COUNT DISTINCT?...
1
by: Andy | last post by:
Hi Gang I have a simple single table that has many duplicate rows in them. The distinctrows only works on more than one table. Is there a quick and easy way to select only the distict rows...
1
by: Damien | last post by:
I have seen examples of selecting distinct elements by name, but my issue is that I need to get distinct attributes by name. My XML looks like: <root> <file> <rows> <row att1="1" /> <row...
4
by: sheraz1 | last post by:
Hi, I am new to VBA, I am trying to create a form that will take the DISTINCT values of a one column and then display all the records associated to that value in the form. I am not sure...
1
by: sampalmer21 | last post by:
Hi, I want to join two tables together and only select the rows that don't have the same customer first name and last name (see my code below). When I run my code with the DISTINCT keyword, it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
marktang
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,...
0
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...
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,...

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.