Jump to content

Least


Asheeown

Recommended Posts

That wreaks of poor database design but ah well.

You need to run a query which retrieves all these values into an array, then sort it. eg;

[code]
<?php
  // connect
  $sql = "SELECT p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12 FROM tbl WHERE companyid = 4;";
  if ($result = mysql_query($sql)) {
    if (mysql_num_rows($result) > 0)) {
      $row = mysql_fetch_array($result);
      sort($row);
      echo $row[0];
    }
  }
?>
[/code]
Link to comment
Share on other sites

I just used the least function for mysql, but another question the least number that it found...is their a way to get that column name

[code=php:0]
$InterQuery = mysql_query("SELECT least(inter1,inter2,inter3,inter4,inter5,inter6,inter7,inter8,inter9,inter10,inter11,inter12) FROM compare_npanxxcost") or die(mysql_error());
[/code]

Showing what column it got the least number out of

For example if "inter3" had the lowest number there, how could you tell that it was in fact "inter3"?
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.