Jump to content

keeB

Staff Alumni
  • Posts

    1,075
  • Joined

  • Last visited

Posts posted by keeB

  1. Here's what I came up with

     

    Given

     

    
    nick@avari ~/code/php $ ls -l -R
    .:
    total 12
    drwxr-xr-x 2 nick nick 4096 Jul 13 13:27 audio
    drwxr-xr-x 2 nick nick 4096 Jul 13 13:27 images
    -rw-r--r-- 1 nick nick 1166 Jul 13 14:02 test.php
    
    ./audio:
    total 0
    -rw-r--r-- 1 nick nick 0 Jul 13 13:27 lol.mp3
    
    ./images:
    total 0
    -rw-r--r-- 1 nick nick 0 Jul 13 13:27 lol.png
    

     

    Output:

     

    
    <a class='myPlayer' href='audio/lol.mp3' style='background-image:url(images/lol.png)'>
                </a>
    

     

    And... here's the code

     

    
    <?php
    
    function directory_to_array($dir) {
        $ret = array();
        $dh = opendir($dir);
    
        while (($file=readdir($dh)) !== false) {
            if ($file != "." && $file != "..") // ignore . and ..
    
                $ret[] = $file;
        }
    
        closedir($dh);
    
        return $ret;
    }
    
    function match_files($audio, $image) {
        //assume basename in $audio and $image are the same
        //merges the two to a new array
        $ret = array();
    
        foreach ($audio as $name) {
            $abase = explode(".", $name);
    
            foreach ($image as $img) {
                $ibase = explode(".", $img);
    
                if ($abase[0] == $ibase[0]) {
                    $ret[] = array($name, $img);
                }
            }
        }
    
        return $ret;
    
    }
    
    function merge_to_player($input) {
        foreach ($input as $pair) {
    
            print "<a class='myPlayer' href='audio/$pair[0]' style='background-image:url(images/$pair[1])'>
                </a>
                ";
        }
    
    }
    
    //get the audio directory contents
    $audio = directory_to_array("audio");
    //get the image directory contents
    $image = directory_to_array("images");
    
    
    $matched = match_files($audio, $image);
    
    merge_to_player($matched);
    
    ?>
    

  2. The addition you'd need to make to your code, then, is to read the images directory in the same fashion as you are the audio directory

     

    The other piece of this, which I assume is what you're having trouble with, is understanding how to merge the two items in your array and display them.

     

    Take a look at building an array that would look like

     

    Array
    (
    
        [0] => Array (
            [0] => song1.mp3
            [1] => image1.png
        )
    . 
    . 
    .
    )
    

     

    Do you know how to do that?

  3. wat about a | will that work too ?

     

    || means OR.

     

    You'd use it like so:

     

    <?php
    
    if ($my_mom == "ghetto" || $my_mom == "white trash")) {
        // if my mom is ghetto or white trash...
        $i = "cannot spell which is why I say 'wat'";
    }
    ?>
    

  4. http://tryit.adobe.com/us/cs4/dreamweaver/tw1/?sdid=ETRPJ

     

    Adobe Dreamweaver is the canonical paid choice for an 'all in one'

     

    You can achieve the same level of success with Free (Open Source) tools such as Eclipse PDT with embedded browser.

     

    I'm of the opinion that each tool should be designed for a particular job and do it extremely well. As such, I shy away from "ALl in one" tools. The tradeoff is to be most productive I require a lot of screen real estate and virtual desktops (provided by linux)

     

     

  5. That might be the coolest name ever. Qadoshyah.

     

    Your form is returning 2 results and isn't very user friendly. Functionality wise it's not very pleasing to use. Being able to search by some other keywords would be nice.

     

     

    When you say you want to incorporate all of the data in to the search, are you taking about the results or the input parameters?

  6. Instead of classes_to_students I'd store the data in the ReportCard table. This way you have a summary all in one table without an intermediary. The classes_to_students recommended by roopert seems a bit over the top for this case.

     

    <?php
    class ReportCard {
        private $student; //fk to student
        private $instructor; // fk to instructor
        private $course; // fk to classes
        private $grade; // A, B, C, D, F
    }
    ?>
    

     

×
×
  • 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.