473,881 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?


Jul 17 '05 #1
2 1926
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
$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($m ax, $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) 3
a) 6

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

USENET would be a better place if everybody read:
Jul 17 '05 #2
"Steven" <we*******@deep web.co.nz> wrote in news:w34ed.1342 9$mZ2.792819
@news02.tsnz.ne t:

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

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 that if I type in any single character all the products that match the criteria should be displayed. So if I typed in an "a" I should get 3 returns (see below) Fields could look like this: product.options: bhw djhsa
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 stay with C and still be able to produce Java byte code for platform independent apps. Also, old programs (with some tweaking) could be re-compiled and ported to the JVM. We have been developing such a tool over the last 2 years and currently...
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 button "Unexpected Error":3251 operation is not supported for this type of object.The demo cd has two databases, one is called inventory and the other just has the tables for the design called inventory data. When you run inventory the database works...
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 db gets updated too. These data need to be instantly displayed on the website. Currently, a SQL DB call is made every few seconds and it's causing big performance issues (which is why this service is not very popular with our clients) What they...
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 it will display the cents, like $35.3 or $35.55, but where there's no cents, it just displays $35. Shouldn't this override any datatypes from the datasource. Just to cofirm I am sending a valid datatype, I checked everything out and this gridview...
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 me "The data has been changed. Another user edited this record and saved the changes before you attempted to save your changes. Re-edit the record." This does not always happen. And yes, I can re-edit the quantity text
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. Note that N = 10. */ #define N 10 #include <iostream> using namespace std;
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 VB.NET ? Thank you.
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
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: 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: 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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.