I have a table with 2 columns I need to sort. The first column is "id" and the second is "job". As jobs are entered into the database they are giving an "id" but if 2 people are working on the same job then the "job" field is given the same number as the "id" field. For example:
id job
1
2
3
4 2
5
So I would like the order to show up as rows with the following id: 1, 2, 4, 3, 5
so that the job show as such: 1, 2, 2, 4, 5
The ordering does not come out correct. Here is the php
PHP Code:
<?php //create order by $query="SELECT * FROM lss WHERE month=$month AND day=$day"; $result = mysql_query($query) or die("Couldn't execute query: ".mysql_error()); while ($rows=mysql_fetch_array($result)) { $id=$rows['id']; $jobdb=$rows['job']; if ($jobdb=="") { $job="id"; } else { $job="job"; } } //list $query="SELECT * FROM lss WHERE month=$month AND day=$day ORDER BY $job"; $result = mysql_query($query) or die("Couldn't execute query: ".mysql_error()); ?>
Last edited by beylah; 01-10-2012 at 12:42 PM..
|