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
https://forums.phpfreaks.com/topic/33807-least/#findComment-158661
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
https://forums.phpfreaks.com/topic/33807-least/#findComment-158662
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.