Jump to content

Archived

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

blacknight

products avaluable

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?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.