Jump to content


Photo

Sorting data on page


  • Please log in to reply
7 replies to this topic

#1 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 05:26 PM

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

#2 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 05:28 PM

Why can't you use order? Could you show us the query?

#3 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 05:41 PM

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.

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 10 October 2006 - 05:49 PM

SELECT * FROM stuff ORDER BY order ASC;

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

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


#5 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 06:08 PM

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.

#6 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 06:30 PM

Help Someone PLEASE

#7 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 07:51 PM

Just getting it back into sight

#8 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 10 October 2006 - 08:18 PM

check out array_multisort(). example 3 is specifically what you're after.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users