Hello,

I have a db with names and corresponding values to the names. I also have a php code to display it all, pulling the info from the db. Now this isn't all very hard, but here's my question....

Per name, I've got up to three values and I would like to let php look for only the lowest value and display only that value. So if it were possible, I need to be able to insert the three values per field in the db and then have a code to get the lowest one, or I need to have three fields with the three values and let php get the lowest one out of those. The only problem there, is that the names per set of values must be the same, though I cannot add in the same name twice in the db.

Another thing... the values are now set to 'numeric float', as I need to multiply the lowest value with another set value. The only way (so far I've found then...) is to do that with float.

Can somebody help me out or at least point me in the right direction? I've searched for hours, but I just don't know where to look for.

Thank you in advance!

Recommended Answers

All 8 Replies

You can try to save these three values in a single field and then when you extract the value from this field then use function named explode to break that value into three different values and then compare them and print them. this would be simple if the values are one digit numbers and if they are greater than that then at the time of saving use a character to differ in between values which you have to use in case of one digit also.Hope this will help you.

regards,
:)shivaniaroraji

Well a bit... The values are prices and they go up to 100000 dollar. Also, the entries have two digits after the point. eg. 123.26 dollar.

Also, these values are set to float and I cannot enter multiple values per cell. eg. 123.26|146.21|109.52. The db won't accept that, since it's set to float.

Do you know how to go further?

i am not sure but you can try to change that float into varchar if possible

Member Avatar for rajarajan2017

If you want to feed multiple values like yours with seperator "|" have a seperate field with varchar datatype and store the value within that.

yes I know, but that's not possible. I need to be able to calculate with those values and that's only able when the value is set to float.

Can anybody help me out here plz?

Can anybody help me out here plz?

Could you post the database schema for the table you are working with? It might make it easier to see what you want.

If I read your question right, you could use SQL to do the selection of lowest or highest value for you:

SELECT MIN(priceFieldName) 
FROM tableName 
WHERE ... 
GROUP BY priceFieldName

I think so too, but the problem is that I've got 23 groups of three prices max. So and that's what I don't know how to do...

Here's a dump of my table. It's a test table, with less entries and only 5 price groups.

-- phpMyAdmin SQL Dump
-- version 3.2.5
--
-- Genereertijd: 09 Aug 2010 om 22:43
-- Serverversie: 5.1.42
-- PHP-Versie: 5.2.12

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `products`
--

-- --------------------------------------------------------

--
-- Tabelstructuur voor tabel `Test_Flyers`
--

CREATE TABLE IF NOT EXISTS `Test_Flyers` (
  `id` mediumint(5) NOT NULL AUTO_INCREMENT,
  `formaatcat` varchar(20) COLLATE utf8_bin NOT NULL,
  `formaat` varchar(100) COLLATE utf8_bin NOT NULL,
  `bedrukking` varchar(50) COLLATE utf8_bin NOT NULL DEFAULT '4/4 Full-Color Voorkant & Achterkant',
  `papiersoort` varchar(50) COLLATE utf8_bin NOT NULL DEFAULT '300g Recyclingpapier, Mat',
  `Info` varchar(255) COLLATE utf8_bin NOT NULL,
  `thumb_formaatcat` varchar(255) COLLATE utf8_bin NOT NULL,
  `thumb_formaat` varchar(255) COLLATE utf8_bin NOT NULL,
  `thumb_bedrukking` varchar(255) COLLATE utf8_bin NOT NULL,
  `thumb_papiersoort` varchar(255) COLLATE utf8_bin NOT NULL ,
  `aantal1` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT '250',
  `aantal2` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT '1000',
  `aantal3` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT '2500',
  `aantal4` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT '5000',
  `aantal5` varchar(20) COLLATE utf8_bin NOT NULL DEFAULT '10.000',
  `prijs1` float NOT NULL,
  `prijs1002` float NOT NULL DEFAULT '123.45',
  `prijs1003` float NOT NULL DEFAULT '123.45',
  `prijs2` float NOT NULL,
  `prijs2002` float NOT NULL DEFAULT '123.45',
  `prijs2003` float NOT NULL DEFAULT '123.45',
  `prijs3` float NOT NULL,
  `prijs3002` float NOT NULL DEFAULT '123.45',
  `prijs3003` float NOT NULL DEFAULT '123.45',
  `prijs4` float NOT NULL,
  `prijs4002` float NOT NULL DEFAULT '123.45',
  `prijs4003` float NOT NULL DEFAULT '123.45',
  `prijs5` float NOT NULL,
  `prijs5002` float NOT NULL DEFAULT '123.45',
  `prijs5003` float NOT NULL DEFAULT '123.45',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=266 ;

--
-- Gegevens worden uitgevoerd voor tabel `Test_Flyers`
--

INSERT INTO `Test_Flyers` (`id`, `formaatcat`, `formaat`, `bedrukking`, `papiersoort`, `Info`, `thumb_formaatcat`, `thumb_formaat`, `thumb_bedrukking`, `thumb_papiersoort`, `aantal1`, `aantal2`, `aantal3`, `aantal4`, `aantal5`, `prijs1`, `prijs1002`, `prijs1003`, `prijs2`, `prijs2002`, `prijs2003`, `prijs3`, `prijs3002`, `prijs3003`, `prijs4`, `prijs4002`, `prijs4003`, `prijs5`, `prijs5002`, `prijs5003`) VALUES
(1, 'A7', '7,4 x 10,5 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A7.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A7.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 32.2, 123.45, 123.45, 35.8, 123.45, 123.45, 44.2, 123.45, 123.45, 51.4, 123.45, 123.45, 70.6, 123.45, 123.45),
(2, 'A7 Lang', '5,2 x 14,8 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A7L.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A7L.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 32.2, 123.45, 123.45, 35.8, 123.45, 123.45, 44.2, 123.45, 123.45, 51.4, 123.45, 123.45, 70.6, 123.45, 123.45),
(3, 'A6', '10,5 x 14,8 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A6.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A6.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 39.4, 123.45, 123.45, 46.6, 123.45, 123.45, 62.2, 123.45, 123.45, 76.6, 123.45, 123.45, 128, 123.45, 123.45),
(4, 'A6 Lang', '7,4 x 21 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A6L.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A6L.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 39.4, 123.45, 123.45, 46.6, 123.45, 123.45, 62.2, 123.45, 123.45, 76.6, 123.45, 123.45, 128, 123.45, 123.45),
(5, 'A5', '14,8 x 21 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A5.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A5.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 52.6, 123.45, 123.45, 67, 123.45, 123.45, 98.2, 123.45, 123.45, 138.8, 123.45, 123.45, 232.2, 123.45, 123.45),
(6, 'A5 Lang', '10,5 x 14,8 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A5L.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A5L.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 52.6, 123.45, 123.45, 67, 123.45, 123.45, 98.2, 123.45, 123.45, 138.8, 123.45, 123.45, 232.2, 123.45, 123.45),
(7, 'A4', '21,5 x 29,7 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A4.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A4.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 79, 123.45, 123.45, 107.8, 123.45, 123.45, 182, 123.45, 123.45, 256.2, 123.45, 123.45, 440.4, 123.45, 123.45),
(8, 'A3', '29,7 x 42 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A3.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A3.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 134.2, 123.45, 123.45, 203.6, 123.45, 123.45, 352, 123.45, 123.45, 502.6, 123.45, 123.45, 871, 123.45, 123.45),
(9, 'Lang', '9,8 x 21 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/L.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/L.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 44.2, 123.45, 123.45, 53.8, 123.45, 123.45, 74.2, 123.45, 123.45, 98.2, 123.45, 123.45, 161.6, 123.45, 123.45),
(10, 'Vierkant Klein', '9,8 x 9,8 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/VK.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/VK.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 34.6, 123.45, 123.45, 39.4, 123.45, 123.45, 50.2, 123.45, 123.45, 59.8, 123.45, 123.45, 91, 123.45, 123.45),
(11, 'Vierkant Groot', '14,8 x 14,8 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/VG.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/VG.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 46.6, 123.45, 123.45, 57.4, 123.45, 123.45, 80.2, 123.45, 123.45, 113.6, 123.45, 123.45, 183, 123.45, 123.45),
(12, 'Vierkant XL', '21 x 21 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/VXL.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/VXL.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 70.6, 123.45, 123.45, 92.2, 123.45, 123.45, 150.8, 123.45, 123.45, 205.8, 123.45, 123.45, 348.2, 123.45, 123.45),
(13, 'Lang', '9,8 x 21 cm met uitgestanst visitekaartje 5,5 x 8,', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/L.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/LV.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 80.6, 123.45, 123.45, 104.6, 123.45, 123.45, 156.2, 123.45, 123.45, 235.6, 123.45, 123.45, 412.2, 123.45, 123.45),
(14, 'A6', '10,5 x 14,8 cm met uitgestanst visitekaartje 5,5 x 8,5 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A6.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A6V.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 75.8, 123.45, 123.45, 97.4, 123.45, 123.45, 143, 123.45, 123.45, 214, 123.45, 123.45, 378.6, 123.45, 123.45),
(15, 'A8', '5,2 x 7,4 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/A8.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/A8.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 28.6, 123.45, 123.45, 31, 123.45, 123.45, 35.8, 123.45, 123.45, 39.4, 123.45, 123.45, 49, 123.45, 123.45),
(16, 'Rond', 'Doorsnede 9,5 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/R.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/R.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 38.2, 123.45, 123.45, 64.6, 123.45, 123.45, 79, 123.45, 123.45, 91, 123.45, 123.45, 135.4, 123.45, 123.45),
(17, 'Ovaal', '14,5 x 9,5 cm', '4/4 Full-Color Voorkant & Achterkant', '300g Mat', 'De hogere grammage maakt de Flyers duurzamer. Gladde oppervlak zorgt voor briljante kleurweergave en de dubbelzijdige dispersielak zorgt voor een extra bescherming.', 'http://www.care4style.nl/Producten/Flyers/Formaten/O.gif', 'http://www.care4style.nl/Producten/Flyers/Formaten/O.gif', 'http://www.care4style.nl/Producten/Flyers/Color_44.gif', 'http://www.care4style.nl/Producten/Flyers/Size_300gMat.gif', '250', '1000', '2500', '5000', '10.000', 43, 123.45, 123.45, 71.8, 123.45, 123.45, 91, 123.45, 123.45, 107.8, 123.45, 123.45, 172.4, 123.45, 123.45);

The 123.45 are test prices, but they are just there to state my point and to give you the table example.

Also, if you take a look here.... This is the complete script I've got atm. Might help you?

Here's the link: Script

Thx!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.