2 Replies - 688 Views - Last Post: 15 November 2009 - 10:41 PM Rate Topic: -----

#1 AUAN  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-July 09

PHP calling files in Wordpress

Post icon  Posted 15 November 2009 - 09:19 PM

Hey all.

I am collecting files from a directory in a wordpress blog with the PHP calling the files onto the page. Now the files come onto the page perfectly, but I was wondering is there any way to create some php that displays the files on screen in alphabetical order?
<?php
				//resources
				global $wpdb;
				$select_files = "SELECT * FROM ".$wpdb->prefix."files";
				$result_files = $wpdb->get_results($select_files);
				foreach($result_files as $files){ ?>
					<h4><a href="/upload_files/resources/<?php echo($files->file_name); ?>"><?php echo($files->display_name); ?></a></h4>
					<p><?php echo($files->description); ?></p>
				<?php } ?>



Above is the current code, and some of the example file names are:
Evalue Research_Evalue Sizing Tool.pdf
Evalue Research_Success Case Method.pdf
Evalue Research_Challenges To Implementing Good Practice.pdf
Evalue Research_Implementing An Experimental Design Method.pdf



Now is there some kind of function in PHP that will start following the file name string after each underscore, and display them in order? I know I could simply upload the files in order, but a more dynamic way is awfully helpful.

Many Thanks!

This post has been edited by AUAN: 15 November 2009 - 09:20 PM


Is This A Good Question/Topic? 0
  • +

Replies To: PHP calling files in Wordpress

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: PHP calling files in Wordpress

Posted 15 November 2009 - 10:17 PM

you can use ORDER BY in your query example: SELECT * FROM ".$wpdb->prefix."files ORDER BY file_name ASC :)

ASC for ascending order and DESC for descending order

Hope it helps :)
Was This Post Helpful? 1
  • +
  • -

#3 AUAN  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 91
  • Joined: 30-July 09

Re: PHP calling files in Wordpress

Posted 15 November 2009 - 10:41 PM

View Postnoorahmad, on 15 Nov, 2009 - 09:17 PM, said:

you can use ORDER BY in your query example: SELECT * FROM ".$wpdb->prefix."files ORDER BY file_name ASC :)

ASC for ascending order and DESC for descending order

Hope it helps :)


Best advice I've had all day. Cheers
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1