Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. Umm, that's not at all like what you said.
  2. 1) the [] in fruit[] is what signifies it as an array, so yes, you need them 2) you check for them the same way as you check any other posted variable, exept that since it's an array, it now becomes a 2d array, so it would look something like this : // assuming they are all checked echo $_POST['fruit'][0]; // echoes apple echo $_POST['fruit'][1]; // echoes orange echo $_POST['fruit'][2]; // echoes banana Now here's the thing: for example, if you check apple and banana but not orange, then your posted array will only have 2 positions in it, not 3 (with the middle one 'empty') so it will now look like this: echo $_POST['fruit'][0]; // echoes apple echo $_POST['fruit'][1]; // echoes banana If for some reason you need to know that Banana was the 3rd checkbox, you can solve that by specifically mentioning the array position in your form like so: <form action=*** method=post> <input type=checkbox name='fruit[0]' value='apple' /> Apple <input type=checkbox name='fruit[1]' value='orange' /> Orange <input type=checkbox name='fruit[2]' value='banana' /> Banana </form> If you do that, then the posted array will look like this: // assuming they are all checked echo $_POST['fruit'][0]; // echoes apple echo $_POST['fruit'][1]; // echoes nothing, it's empty echo $_POST['fruit'][2]; // echoes banana 3) I think that was probably answered somewhere in 1 and 2 edit: seems like madtechie beat me to the punch.
  3. Easiest way to have a column associated with the user that gets updated with the current time, every time they make a request to the server (click a link, submit something, etc..) and then setup a cron job script and run it every x time (like 15 mins or so..however long you want to deem "inactivity" to be considered "logged out") to check the current time with the last active time of users and if it's greater than your x time, flag their status as offline.
  4. Well here's my take. I'm sure there is a more elegant way of doing it, but...yeah. What I did was break it down into 3 separate loops. I tested it with a test table on my own db so you're gonna have to plug in your own vars and names, obviously. <?php $sql = "select tutorial_title from tutorial"; $result = mysql_query($sql); $x = 0; // keep track of what col we're on echo "<table border = '1'><tr>"; // start of table while ($list = mysql_fetch_assoc($result)) { // start of loop if ($x == 5) break; // break the loop when we have 5 echo "<td>{$list['tutorial_title']}</td>"; // echo info out $x++; // inc to next col pos } // end loop echo "</tr><tr>"; // end and start next row // this loop is a little more complicated, since // there will be several rows with 4 columns $x = 0; // keep track of which col we're on $y = 0; // keep track of which row we're on while ($list = mysql_fetch_assoc($result)) { // start the loop if ($x == 4) { // if we have 4 cols displayed... echo "</tr><tr>"; // end and start a new row $y++; // move row counter to next pos if ($y == 4) break; // if we reach 4 rows, we end the loop $x = 0; // otherwise, we reset col counter and keep going } // end if echo "<td>{$list['tutorial_title']}</td>"; // echo data out $x++; // move to next col } // end loop $x = 0; // start col counter over for last loop echo "</tr><tr>"; // end last row of last loop and start new row while ($list = mysql_fetch_assoc($result)) { // start last loop if ($x == 3) break; // if we have 3 cols, end loop echo "<td>{$list['tutorial_title']}</td>"; // echo out info $x++; // move to next col count } // end last loop echo "</tr></table>"; // close the last row and the table ?>
  5. I wasn't being an elitist jerk. You were asking for help on your homework. I was simply stating the rules. I don't feel there was any sarcasm at all involved in my post. I'm sorry you took it that way. I guess you just enjoy shooting the messenger. That whole comma thing doesn't really have anything to do with your form; I think you misunderstood. // example $to = "[email protected], [email protected]"; // comma separated email addresses here $subject = "blahblahblah"; $message = "lots of more blah"; mail($to,$subject,$message); ...or if that isn't the issue, then maybe I'm not understanding you.
  6. umm..hmm. I don't really see how that loop could possibly be giving you 50 different results...I mean, the code you posted in that link clearly shows you making $new_img_link an array with only one position...have you changed your code somehow since then? But regardless, you have your query outside the foreach loop, so no matter how many positions are in that array, $img_link is going to be the last iteration of that loop, and your query is going to insert that last iteration value on every single iteration on your outer foreach loop.
  7. Is $m supposed to be an array? Did you mean to put a loop around that 2 line code of yours I posted, iterating the position in $m? Because if so, that should probably solve your issues.
  8. Thread closed. Please do not make multiple threads asking the same thing.
  9. Didn't you already ask this in another thread? You are updating achimg with $img_link which is an iteration of $new_img_link which is supposed to be an array but here: $new_m = strrchr($m[0], '/'); $new_img_link[] = $new_m; strrchr starts at the last occurance of the needle in the haystack and returns from there until the end of the haystack; that is, a string is being returned, so your $new_img_link is not really an array. Well, it's an array with 1 position, which makes it a glorified variable. So your foreach loop isn't doing squat but iterating once.
  10. The proverbial which came first, the chicken or the egg?
  11. $sql = "SELECT * FROM user WHERE user.id='{$_GET['id']}'"; I'm also curious why you are running this query and then later checking to see if it exists in the first place?
  12. how about trying a group by? I suck at sql I'll forward your thread to the sql forum they'd be able to help out better.
  13. I believe he was telling you two different things. 1) take that line out. while it's just a variable, it calls mysql_fetch_assoc, which will push the internal pointer up a notch in your result source, making you miss the first one in your while loop. 2) the problem is in your query string, as your loop is fine. I'd look into that DISTINCT.
  14. In the future, please use php or code tags around your script, if you want anybody to take you seriously. You said you got it working to send to one person; sending to two people is just a matter of adding a comma after the first email address and adding another email address, in your $my_email variable. As to your second question: We don't do people's homework for them.
  15. Nope sorry, not the way it works. We can lock it but we won't delete it.
  16. Or maybe someone is going back and editing your post and putting them in, since you aren't?
  17. I've already told you twice how to do it. Use an array and do a condition to check if the user level number is in the array. I've provided the code for you, twice. I see conditions all over your script, so you seem to know what those are about. What exactly are you having trouble with, as far as making a simple array and checking if your number is in_array(..)? No offense, but I really don't see how I can make it any simpler than giving you a working example..which I already did. I mean, I see you using list() which is like, 1 step away from arrays. Or maybe a cousin once removed, or something. Do you want me to write your code for you? I'm available, for a modest fee.
  18. no not really...unless the script being executed takes long enough time to execute that he happens to be getting a whole bunch of requests at the same time...the connection is automatically closed at the end of the script. The only time it's really useful to use mysql_close is if you're done with mysql at the top of your script and you have a (large) amount of code left to run, it will just free it faster.
  19. If I understand correctly, about 2gb is the max, but that's if something doesn't timeout before that...
  20. All of the pagination tutorials pretty much have the same code. The only real difference is in the author's preference of certain interchangeable functions, etc.. and perhaps a feature or two thrown in there for good measure (like making the columns clickable sortby links, etc...). There really isn't a whole lot to pagination...
  21. You're right. The basic setup to do a small xhttprequest or whatever that darn thing is called looks very scary at first sight, but if you take deep relaxing breaths, clear your mind and then give it a proper look, there's really not much to it. 99% of it is just a couple of functions that set it all up and you don't really have to do anything with it at all.
  22. Well, no...the way I said it was slightly different. There wouldn't be a giant loop looping through everything. Your way won't work because that popup that which you speak of won't actually popup until the php is completely done executing, in other words, at the end of the loop.
  23. Not going to work. PHP is a server side language. It's all processed first and then sent to the client. Best you can do on that count is to make a script utilizing your db like you said, but instead of looping through everything you do it one at a time and that's it, but check the db each refresh with a meta refresh every second or so and do a new query based on that. Throw on a condition before all that to see where the number is in that extra column and stop when it reaches. It sounds terribly complicated and inefficient because it is. Go the AJAX method. Google AJAX loader/percent bars, you know, the ones you see going from 0-100% to show something is loading. You would base the % off of what iteration you're at vs. how many total. Just have an updated number instead of a load bar. Or you can have a load bar that fills up, because it would look more flashy and cool and it might score you a date with that hot chick in accounting.
  24. You need to reorder your code to do your query after where you change the name in your script so you can use that instead.
  25. Very scary. Turn them off. Never use them. The end.
×
×
  • 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.