What would be the best way or how should i say do i sort images that are named numerically in order?
this is my original code, i was told that it should sort perfecty fine with what ive got but it doesn't.....its all mixed up
Expand|Select|Wrap|Line Numbers
- <?php
- $path = "upload/$random_digit/images/"; // path to the directory to read ( ./ reads the dir this file is in)
- if ($handle = opendir($path)) {
- while (false !== ($file = readdir($handle))) {
- if ($file != "." && $file != "..") {
- if(!is_dir($file)){
- $item[] = $file;
- }
- }
- }
- closedir($handle);
- }
- $total_items = count($item);
- $max_items = ceil($total_items / 5); // items per <td>
- $start = 0;
- $end = $max_items
- //generate the table
- ?>
- <center>
- <table width="675px" border="0" cellspacing="5" cellpadding="5" align="center">
- <tr>
- <?php
- $r = 0;
- $pn=1;
- $pto=1;
- for($n=0; $n<$total_items; $n++) {
- if($n !=0 && fmod($n, 5) == 0) {
- echo "</tr><tr>";
- }
- $imageL= $path.$item[$n];
- if (substr($imageL,-5) != 'b.jpg')
- {
- $img_path="http://theauctionwinners.com/resources/$imageL";
- $editLink = "http://theauctionwinners.com/resources/imgEdit.php?img=$img_path";
- $iframeName= 'if1';
- $iframeHeight= '955px';
- $click= 'onClick';
- // display the item
- echo '<td><center><p><a href="'.$img_path .'"><img src= "'.$path.$item[$n] .'" height="100" width="100"></a></p></center>';
- echo '<center><p><input type="hidden" name="picT[]" value="pic'.$pn++.'"/></p></center>';
- echo '<center><p><input type="hidden" name="photoT[]" value="PHOTO '.$pto++.'"/></p></center>';
- echo '<center><p><input type="text" name="captionT[]" value=""/></p></center>';
- echo '<center><p><a href="'.$editLink .'" '.$click.'="document.getElementById('.$iframeName .').height='.$iframeHeight .'; document.getElementById('.$iframeName .').src=this.href; return false;"> > Edit Image < </a></p></center><br></td>';
- }
- }
- if($r>0) {
- for($m=$r; $m<5; $m++) {
- echo "<td> </td>";
- }
- }
- ?>
- </tr>
- <td><tr><center><input name="create" type="submit" value="Submit" /></center></tr></td>
- </form>
- </table>