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

Displaying "Highest Price" indicator

Hi there,

I have a list of values that I am displaying in a table (Not using a loop)

I want to be able to put a graphic next to the item with the hightest price.

I have all of the prices in a table.

Any ideas?

Cheers

Steven
Jul 17 '05 #1
2 1895
Steven wrote:
I have a list of values that I am displaying in a table (Not using a loop)
Well ... you now have to do a loop.
I want to be able to put a graphic next to the item with the hightest price.
Find the highest priced item *before* printing the items; when printing
only put the graphic if it is the right item.
I have all of the prices in a table.
A database table?
How do you get and print data from the database without loops? ?!?!?!
Any ideas?


Adapt this simple script that uses no database:

php$ cat max.php
<?php
$data = array(4, 7, 18, 3, 18, 6);

echo "Version a:\n";

$max = max($data);
foreach ($data as $value) {
echo ' a) ', $value;
if ($value == $max) echo ' GRAPHIC';
echo "\n";
}

echo "\nVersion b:\n";

$max_index = array_search($max, $data);
foreach ($data as $k=>$v) {
echo ' b) ', $v;
if ($k == $max_index) echo ' GRAPHIC';
echo "\n";
}

?>

php$ php max.php
Version a:
a) 4
a) 7
a) 18 GRAPHIC
a) 3
a) 18 GRAPHIC
a) 6

Version b:
b) 4
b) 7
b) 18 GRAPHIC
b) 3
b) 18
b) 6

--
USENET would be a better place if everybody read:
http://www.expita.com/nomime.html
http://www.netmeister.org/news/learn2quote2.html
http://www.catb.org/~esr/faqs/smart-questions.html
Jul 17 '05 #2
"Steven" <we*******@deepweb.co.nz> wrote in news:w34ed.13429$mZ2.792819
@news02.tsnz.net:

Any ideas?


sort a copy of the array from high to low, get the price in the first row,
check the next one to be sure there isnt more than one with the same price
(unless you are certain this cannot happen). That way you wont have to
search the whole array but will only last for one row, or however many
there are of the same high price. When you print out your list, use an if
statement to see if the current price equals the high price, if so then
print your graphic.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Peter | last post by:
My problem is the last bit of coding below, the like statement does not work. what I have is a product options field and in it is stored characters i.e. "avcy" etc what the query does is...
289
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
5
by: Kiki | last post by:
Hello all. Probably I should be sending this to a different group so apologies if this seem out of place. We have an Access db in which people change data - as they do. When they do that, our SQL...
3
by: David Lozzi | last post by:
Howdy, In my GridView i have some bound columns displaying currency. I have DataFormatString="${0:C2}" in one of the columns but the value being displayed is $35 . If the price has cents, then...
7
by: PW | last post by:
Hi, I have a form with unbound fields on it. The user selects a record from a recordset and I populate the unbound fields. When I try to change the unbound quantity text box, Access 2003 tells...
3
by: lostncland | last post by:
I am working on this program. The array has 10 scores. (there is more to this program.) Does the last "for" section make sense? /*Defines a global constant called N throughout the file. ...
6
by: fniles | last post by:
Say price = 4179.00 or 4179 In VB6, when I do Format(price, "#.0"), it returns 4179.0, but in VB.NET when I do String.Format(price, "#.0"), it returns 4179.00. How can I do Format(price, "#.0") in...
25
by: Peng Yu | last post by:
Hi, It is possible to change the length of "\t" to a number other than 8. std::cout << "\t"; Thanks, Peng
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.