Jump to content

Archived

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

GremlinP1R

Sorting data on page

Recommended Posts

Hi There

I have now with a lot of effort and a huge script got to a point I just have to sort some data.
But now I cant use the Order by in the mysql_query as the number it sould be sorted by is after all the proceses. I have got a $d_id that = to a 2digit number. How do I sort information only using the page and not the database?

using $row = mysql_fetch_array() to display  all data on page!

Please help if possible. Thanx

Share this post


Link to post
Share on other sites
thats the problem it not in a query, the data get puled from the database get changed and everything and then the digit only exist with what it has to be orderd by, The query's order are from the database.

Share this post


Link to post
Share on other sites
[code]SELECT * FROM stuff ORDER BY order ASC;[/code]

Or if you got a table for the orders then something like this:

[code]SELECT s.*,o.* FROM stuff AS s LEFT JOIN orders AS o ON s.id=o.oid ORDER BY o.order ASC;[/code]

Share this post


Link to post
Share on other sites
hehe Daniel where not on the same wave lenght here, wait let me try again.

Okay I'm using a search function to search the data base for a sertian part of a 13digit number

if (isset($_POST['Get'])){
  if ($select == Num32){$result = mysql_query("SELECT * FROM table WHERE row LIKE '__32_________' ORDER BY row ASC ") or die();}
  elseif ($select == Num27){$result = mysql_query("SELECT * FROM table WHERE row LIKE '__27_________' ORDER BY row ASC ") or die();}

then after that I'm getting it to show but with a twist that digit is a 13digit numer searching using position 3 and 4 op the number. There after I I put it on the page.

// keeps getting the next row until there are no more to get
      while($row = mysql_fetch_array( $result )){
  // Print out the contents of each row into a table
      echo "<form action='individualsdetaiils.php' method='post'>";
        $ref = $row['ID'];
$bid = $row['idno'];
if ($bid != 0){
$d_id = $bid{4}.$bid{5};
$m_id = $bid{2}.$bid{3};
if ($m_id == 1){$m_id = one;}
elseif ($m_id == 2){$m_id = two;}
elseif ($m_id == 3){$m_id = three;}
elseif ($m_id == 4){$m_id = four;}
          echo "</td><td>";
          echo $row['Names'];
  echo "</td><td>";
  echo "$d_id $m_id";
  echo "</td><td>";

Now what I want to do is sort by $d_id that is created here after the query. the $d_id is position 5 and 6 in the 13digit number.

Share this post


Link to post
Share on other sites
check out [url=http://www.php.net/array_multisort]array_multisort()[/url]. example 3 is specifically what you're after.

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.