I've got a sorting question that I can't figure out. The page in question is here:
http://toolstudios.com/intera/careers/index.php
I'd like it to show up like this: Accounting job 1 job 2 Engineer job 1 job 2 IT job 1 job 2
Basically, I'd like the categories of employment to be alphabetical. Here's the SQL stuff now:
<?php include("common.inc");
$connection = @mysql_connect("$db_host","$db_user","$db_pass") or die("Couldn't Connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql ="SELECT id,status,title,summary,description,post_date,hidden,job_id,contact_emai l
FROM careers
WHERE hidden = '2'
ORDER BY job_id,title ";
$result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
while ($row = mysql_fetch_array($result)) {
$id=$row['id'];
$status=$row['status'];
$title=$row['title'];
$summary=$row['summary'];
$description=$row['description'];
$post_date=$row['post_date'];
$hidden=$row['hidden'];
$job_id=$row['job_id'];
$contact_email=$row['contact_email'];
// lookup sub_cat name and display, only if it's new
if ($job_id != $old_job_cat){
// New Connection and selection from Sub Category db
$connection = @mysql_connect("$db_host","$db_user","$db_pass") or die("Couldn't Connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$cat_sql ="SELECT job_id, category FROM career_categories WHERE job_id = '$job_id' ORDER BY category ASC";
$cat_result = @mysql_query($cat_sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error());
while ($cat_row = mysql_fetch_array($cat_result)) {
$job_id=$cat_row['job_id'];
$category=$cat_row['category'];
// We then print out the RESULT row
$job_heading = " <br>\n <FONT SIZE=\"4\"><B>$category</B></FONT>\n";
$display_block .= "$job_heading <br>\n";
}
}
// This ends the Sub Cat Row, and continues the Job Listings Row
$old_job_cat = $job_id;
$display_block .= " <a href=\"detail_action.php?id=$id\">$title</a> - $summary<br>\n";
}
$num = @mysql_num_rows($result);
if ($num != 0) {
include("list_results.php");
} else {
include("list_no_rslt.php"); }
?>
The problem is, when the script looks for "job_ID" and attempts to see if it matches anything, it doesn't return an array of results...just 1. So, can't really alphabetize one result. Any workarounds?
Thanks,
mto
--
Michael O'Neal Head Honcho http://www.WhirledMedia.com [EMAIL PROTECTED] Boulder, Colorado 720.436.2922 IM: AOL-emptyo1 MSN: [EMAIL PROTECTED] Yahoo: bambisapartment
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]