Jump to content

Search the Community

Showing results for tags 'natsort'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Greetings all, So I'm starting to play around with incorporating databases into dynamic pages and I've come across an issue that was only vaguely covered during my PHP course in college. The script below works great except that it needs a natsort and I'm not sure how to do a natsort and still make the while loop work. I'm not even sure how to go about writing it. The script queries the database for the video names, video descriptions and then turns them into links (with a little css and java help). But after video 9 it starts to order incorrectly. It goes ...1, 10, 11, 12, 2, 3, 4, 5.... you get the idea, needs a natsort. I just don't have a clue how to go about doing that and keeping the while loop working. I tried a couple things but I'm just not figuring this out. <?php require ('masters/connect.php'); // Define the query: $q = "SELECT * FROM videofiles WHERE folder='" . $sect . "' ORDER BY vidname"; $r = @mysqli_query ($connect, $q); // Count the number of returned rows: $num = mysqli_num_rows($r); if ($num > 0) { // Table header: echo '<h1>Section Lessons</h1>'; echo '<table id="link-table">'; // Set up array to remove beginning url from database section names. $sectpattern = $sect; $patterns = array(); $patterns[0] = '/videos/'; $patterns[1] = '/\//'; $patterns[2] = '/' . $sectpattern . '/'; $patterns[3] = '/\\.[^.\\s]{3,4}$/'; $replacements = array(); $replacements[0] = 'Lesson '; // Fetch and print all the records: while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr> <td>' . "<a href=\"javascript:create_window('".$row['vidname']."',640,360)\">Click Here</a>" . '</td> <td align="left"> <div id="tabledataimage1"> <img src="'. $row['vidimage'] .'" width="100"/> </div> <div id="tabledatatitle1"> <h4>' . preg_replace($patterns, $replacements, $row['vidname']) . '</h4> </div> <div id="tabledatadesc1"> ' . $row['viddesc'] . ' </div> </td> </tr>'; } echo '</table>'; mysqli_free_result ($r); } else { // Inform that no entries were returned from the query. echo '<p>There are currently no videos in this section.</p>'; } // Close database connection: mysqli_close($connect); ?> As always any help is greatly appreciated. I'm having a lot of fun learning PHP but I still have a long ways to go. Best Regards, Nightasy
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.