LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2005, 09:30 AM   #1
brandor
LQ Newbie
 
Registered: Apr 2004
Posts: 29

Rep: Reputation: 15
Quick MySQL question


Alright, here is the deal.

I was asked, several months ago, to make a simple job database. They didn't want any sorting or anything like that. So, ok gotcha that's easy. I popped it out in a few days for them. Fast forward to last week. They asked me to flop the way the database info displays (lastest entry first). So. I think... no problem. BZZZT.

Since I haven't touched MySQL or php since then, I've forgotten everything!! Can anyone help me? This is the script I have running now:

Code:
       //Connect to the server and select the db
	$link = mysql_connect("localhost", "root") or die("Can not connect to the server. If you continue to see this error, please contact the Administrator.\n");

  	mysql_select_db("joblistings",$link) or die("Can not select the database. If you continue to see this error, please contact the Administrator.\n");

  	//Pull info from the table.
  	$query = "select * from shortJobs";

  	$result = mysql_query($query) or die("Could not query the database. If you continue to see this error, please contact the Administrator.");

  	//Display jobs that are currently showing.
  	while($line = mysql_fetch_array($result, MYSQL_ASSOC)){
		if($line[visible]){
			echo "<p class=\"body\">\n";
			echo "<strong><center>Job Announcement</center></strong><p>";
			echo "<strong>Location:</strong> $line[location]<br>\n";
			echo "<strong>Date Received:</strong> $line[dateReceived]<br>\n";
			echo "<strong>Job Title:</strong> $line[jobTitle]<br>\n";
			if($line[firm]){ echo "<strong>Firm:</strong> $line[firm]<br>\n"; }
			echo "<strong>For Class Years:</strong> $line[forYears]<br>\n";
			echo "<strong>Salary:</strong> $line[salary]<br>\n";
			echo "<strong>Deadline:</strong> $line[deadline]<br>\n";
			echo "<strong>Contact:</strong> $line[contact]<br>\n";
			echo "<strong>Submit:</strong> $line[submit]<br>\n";
			echo "<strong>Notes:</strong> $line[notes]<br>\n";
			echo "</p>\n";
		}
	}
All I need is to have the records displayed last record to first record.

Also, here are the fields of the DB:

Code:
+--------------+------------+------+-----+---------+----------------+
| Field        | Type       | Null | Key | Default | Extra          |
+--------------+------------+------+-----+---------+----------------+
| id           | int(11)    |      | PRI | NULL    | auto_increment |
| location     | text       | YES  |     | NULL    |                |
| dateReceived | text       | YES  |     | NULL    |                |
| jobTitle     | text       | YES  |     | NULL    |                |
| forYears     | text       | YES  |     | NULL    |                |
| salary       | text       | YES  |     | NULL    |                |
| deadline     | text       | YES  |     | NULL    |                |
| contact      | text       | YES  |     | NULL    |                |
| submit       | text       | YES  |     | NULL    |                |
| notes        | text       | YES  |     | NULL    |                |
| firm         | text       | YES  |     | NULL    |                |
| visible      | tinyint(1) | YES  |     | NULL    |                |
+--------------+------------+------+-----+---------+----------------+
12 rows in set (0.00 sec)
Thanks in advance!
Brandon
 
Old 03-02-2005, 09:40 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Code:
$query = "select * from shortJobs order by id desc";
 
Old 03-02-2005, 09:45 AM   #3
brandor
LQ Newbie
 
Registered: Apr 2004
Posts: 29

Original Poster
Rep: Reputation: 15
Sweet! I knew I was forgetting something stupidly simple like that.

Thanks a lot!
B
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
quick mysql question - logic with COUNT BrianK Programming 3 09-29-2005 04:29 PM
webmin+mysql a quick question pudhiyavan Linux - Software 0 01-13-2005 08:07 PM
Question Concerning ISO's and one quick question. evrae Linux - Software 2 06-21-2004 03:53 AM
samba smb.config question (quick question) TheDOGG Linux - Networking 1 03-02-2004 07:19 AM
quick question OtisLinux Linux - Software 3 02-20-2004 12:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration