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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.