Jump to content

products avaluable


blacknight

Recommended Posts

we have a database where we store computer parts and we use these parts to build systems this is what i need to know say i have somthen like this

video card x 10
mobo        x 5
Ram        x 7
Hdd          x 9

no by looking at this i can see that i can make 5 systems but i was a php script that compares up to 10 compoments and tells me how many i can make can some one help me with this?
Link to comment
https://forums.phpfreaks.com/topic/20038-products-avaluable/
Share on other sites

Assuming 1 of each per system

[code]<?php
$parts = array(
        'video card' => 10,
        'mobo'      => 5,
        'Ram'        => 7,
        'Hdd'        => 9
);

echo min($parts);    // --> 5
?>[/code]

Or, direct from DB,
[code]<?php
$sql = "SELECT MIN(qty) FROM parts";
$res = mysql_query($sql);
echo mysql_result ($res, 0, 0);
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/20038-products-avaluable/#findComment-87932
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.