Jump to content

jackmn1

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jackmn1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks requinix, you described exactly what I want to display, but how should I write the left join? should I use a subquery such as this? LEFT OUTER JOIN (SELECT COUNT(faves.user_id) AS topFaves, faves.created_on, user_name, id FROM users INNER JOIN faves ON faves.user_id= users.id WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= created_on GROUP BY id ORDER BY topFaves) weekFaves ON weekFaves.id = users.id And what should I do with the where clause already in the parent query? I'm also not sure how to allow the null...
  2. It gives a list of the users by the number of faves they got. If you add the WHERE to it, it displays only the users that got top faves the past week.
  3. I have the following query that outputs users with the highest number of favorites that they received in the past week in descending order: SELECT COUNT(faves.user_id) AS topFaves, faves.created_on, user_name FROM users INNER JOIN faves ON faves.user_id= users.id WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= created_on GROUP BY id ORDER BY topFaves DESC LIMIT 10 I would like to be able to extend this list to contain all users, not just from the past week, but still order them by the same criteria (the number of favorites they got in the past week). I tried to include a subquery in the select but didnt have any luck with it. Thanks in advance for any help
  4. It works! it wasn't the path eventually, I just realized that there was another is_dir I needed to change to !is_file now. Thanks a lot, kickstart. I appreciate your help.
  5. the script is located in the folder project/extra/scripts/index.php. So what should $dir value be?
  6. This seems to work a lot better, however, I now noticed that it works only if I leave the $dir variable as $dir = "./", but it doesn't work with $dir = "./project/sys". This is strange, maybe I'm entering the path incorrectly (I'm still a newbie in PHP..).
  7. I did remove the ".." and "." conditions, but is_dir still doesn't work :-(
  8. Great! but the function doesn't output anything, and after debugging, I found out that for some reason it doesn't meet the condition "is_dir". Do you have any idea what might be the reason?
  9. Thanks, kickstart, that helps a lot. But the folders I listed are just an example and there are in fact many many more subfolders to project/sys. Therefore I need to somehow find the subfolder list (only 1st level children), and loop through that list instead of the: if ($txtFiles=find("project/sys/diagram","*.txt")) echo "Folder project/sys/diagram contains a text file<br />" ; if ($txtFiles=find("project/sys/bin","*.txt")) echo "Folder project/sys/bin contains a text file<br />" ; if ($txtFiles=find("project/sys/scripts","*.txt")) echo "Folder project/sys/scripts contains a text file<br />" ; Can you show me how to do this?
  10. I need to create a function that lists subfolders of a given folder, that contain at least one .txt file. I found the following function, which displays a list of file that match a pattern in a directory tree: function find($dir, $pattern){ $dir = escapeshellcmd($dir); $files = glob("$dir/$pattern"); foreach (glob("$dir/{.[^.]*,*}", GLOB_BRACE|GLOB_ONLYDIR) as $sub_dir) //look in subdirectories { $arr = find($sub_dir, $pattern); //recursive call $files = array_merge($files, $arr); // merge array with files from subdirectory } return $files; } $txtFiles=find("project/sys","*.txt"); foreach ($txtFiles as $txtFile) { echo '<h2>'.$txtFile.'</h2>'; //display all text files } My question is, how do I change the function to return only folders that contain at least one text file. But, the functions should look inside child folders of "project/sys" and list a child folder only once if that folder or any of its child folders contain at least one text file. I'll give an example of the output I'm looking for: Folder list project/sys/diagram project/sys/bin project/sys/scripts project/sys/styles project/sys/meta The above folders may not contain a text file directly, but their children folders do. However, I'm not interested in their children folder and I want to list the above level folder only once for each folder. Thanks in advance
  11. I appreciate your answer Phil. The form is using Post and the server doesn't save the info to db. I can only hope the client will contact again. Thank you.
  12. Hi, I have setup a standard contact form that sends an email using php "mail" function in my new website. Today, I received an email from a potential client through my website. However, unfortunately, I did not receive the user's email address because (as I discovered after wards), there was a syntax problem in the function, so all I received is their name and message. I am certain that the user has entered their email address because the form has validation, it just didn't send me the address so I have no way to contact that client... Is there a way to retrieve the lost email address from the server somehow? Thanks in advance
  13. Thank you thorpe. Just in case anyone is interested I have the answer in PHP: $content = preg_replace('/(<img [^>]+>)/','<li>\1</li>',$content );
×
×
  • 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.