Jump to content

keeB

Staff Alumni
  • Posts

    1,075
  • Joined

  • Last visited

Everything 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. || 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. Can you post a DDL of your database and the query you are currently using to generate results of your search?
  5. 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)
  6. 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?
  7. There wouldn't be one canonical person who does the grading for a course?
  8. 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 } ?>
  9. I am working on a project which requires analysis and generation of a Cartesian Product for a list of Products which go together. Ideally, you'd be able to group the list of Product's by price range (low, mid, high.) Given this task, how would you accomplish it? I'll be happy to share snippets of my results as the post matures.
  10. I suppose you should use http://php.net/include Makes sense doesn't it?
  11. Invisible iframes ftw
  12. Slimmer != better. This guy is writing in dreamweaver. That tells you he's not ready for short hand if statements.
  13. No, I mean -- I now know the username and password to your database. This is not a good thing.
  14. I suggest removing your db username and password from that code snippet.
  15. Only thing there is tracking sessions. If session has been idle for > $threshold, increment counter by 1 and close session.
  16. How is your mail server connected? Can you send an email without doing it through PHP?
  17. Yes. It means you got in. http://php.net/mysql_connect It clearly states it returns FALSE if it fails to connect.
  18. But you want to do it when the page closes. You might be able to do something on the <body unload attribute, but I am not entirely sure.
  19. Can you show us your updated search code?
  20. $q = "select * from table_where_emails_are_stored..."; $ret = mysql_query($q); print '<select name="email">'; while ($row = mysql_fetch_assoc($ret)) { $email_addr = $row['email']; print "<option value=\"$email_addr\">$email_addr</option>"; } or something
×
×
  • 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.