Jump to content


  • Posts

  • Joined

  • Last visited


Profile Information

  • Gender
    Not Telling

stephenk's Achievements


Member (2/5)



  1. Excellent, thanks very much, now working! Stephen
  2. I have the following very basic code, however it keeps alerting "0" as the table row count, despite the fact I have a properly formed table in the body. function count() { var myTR = document.getElementsByTagName('tr'); alert(myTR.length); } count(); Full code as follows: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="javascript"> function count() { var myTR = document.getElementsByTagName('tr'); alert(myTR.length); } count(); </script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <table width="200" border="1"> <tr> <td>f</td> <td>f</td> <td>f</td> <td>f</td> <td>f</td> </tr> <tr> <td>ef</td> <td>ef</td> <td>ewf</td> <td>ewf</td> <td>ff</td> </tr> <tr> <td>e</td> <td>e</td> <td>e</td> <td>te</td> <td>tew</td> </tr> </table> </body> </html> Any help greatly appreciated, Stephen
  3. Yeah, well spotted, I usually do that, but the code I quickly wrote out was just for simplicity, not code from my script Thanks for that, good idea, however because of the nature of ereg, it obviously won't always be suitable! Likewise with GingerRobot's solution. I just assumed that there would be some sort of way to do it when not using numbers (which I just used as an example). Cheers, Stephen
  4. I've worked out the eregi one, it can be done using: <?php if(eregi("(abc|bcd|cde)",$1) {} else {} ?> Anyone got any ideas for the if statement?
  5. I had this problem recently. It gets really messy, but here is my solution ... <?php // $filter_age is the value taken from the database, instead of age ranges, you have fruits. <select name="filter_age"> <option value="-">All</option> <option value="2-5"<?php if($filter_age == "2-5") {echo ' selected = "selected"';}?>>2-5</option> <option value="6-12"<?php if($filter_age == "6-12") {echo ' selected = "selected"';}?>>6-12</option> <option value="13-15"<?php if($filter_age == "13-15") {echo ' selected = "selected"';}?>>13-15</option> <option value="16-25"<?php if($filter_age == "16-25") {echo ' selected = "selected"';}?>>16-25</option> <option value="26-39"<?php if($filter_age == "26-39") {echo ' selected = "selected"';}?>>26-39</option> <option value="40-59"<?php if($filter_age == "40-59") {echo ' selected = "selected"';}?>>40-59</option> <option value="60-100"<?php if($filter_age == "60-100") {echo ' selected = "selected"';}?>>60+</option> </select> ?> I built this up quite gradually, but I realised after writiting this code that a much neater solution would be to place all the ages (fruits) in an array, then loop through the array and check if the value from the array matches the value from the database. If so, echo "selected = 'selected'. Stephen
  6. Hi, I know there is a sortcut to do the following, but I cannot find it anywhere. <?php if($a = "1" or $a = "2" or $a="3") {} else {} ?> likewise ... <?php if(eregi("abc", $1) or eregi("bcd",$1) or eregi("cde",$1)) {} else {} ?> I think it involves square brackets and the | symbol, but I can't get the combination right! Many thanks, Stephen
  7. I have now spotted the problem, and yeah, its to do with register_globals. It's because I'm using a POST HTML name the same as a variable name, just for convenience within the script. What a nightmare. Thanks for helping me find the problem. Stephen
  8. Nope, no sessions or cookies. I closed the firefox tab and re-opened. Now it's back to normal. However I don't think that doing that would have cleared the session cookie, even if it was set. It seems so strange!
  9. They are, yeah. I thought register_globals only meant anything when using $variable instead of $_GET['variable']? When I run the script saying $variable="" ..., then run a script saying echo $variable it still returns the contents from ages ago. :S Stephen
  10. I have been working on a script and it worked perfectly on my local server. However when I uploaded it I had problems due to a few variables acting strangely. Eventually i deleted all the script's contents and entered this: <?php echo $variable; ?> and I found that, when uploaded and ran, it returned the contents that I had set when running the full script earlier. I have now gone to the point of declaring all variables for the script using $variable=""; ... etc at the start. Has anyone had experience of this happening before? It took me about 30 mins to finally debug what was happening! Stephen Edit: sorry, just realised I posted in the mysql forum, please move it to the PHP one if necessary!
  11. Yeah, I just worked that out about a minute before you replied. You had actually used $upper twice but I changed the wrong one. Gets a bit confusing sometimes! Thanks again, you saved me alot of bother. Stephen
  12. Thanks for your help. However I'm running this query: SELECT * FROM tblpeople WHERE `dob` BETWEEN CURDATE( ) - INTERVAL 1 YEAR AND CURDATE( ) - INTERVAL 10 YEAR There are people in the table with DOBs ranging from 1983-05-05 to 2002-09-07 and the query isn't returning any records. Stephen Edit... Got it: I had got the upper and lower switched round - In your query above you had upper twice and I changed the wrong one. Thanks for your help!!
  13. I have an age range coming in as a POST variable in the form a-b where a is the lower boundary and b is the upper one. In my database, the DOB of various people are stored. Can anyone tell me the BETWEEN query to select the people that are within the age range $lower and $upper, according to their date of birth? I really hate working with dates! Many thanks, Stephen
  14. Personally, I wouldn't submit any of my PIN codes/passwords to that site. It looks quite unprofessional especially with some elements (i.e. the forms) which appear to be copied and pasted code. If my internet connection dies, I have lost my passwords. The system I use (Encrypted on hard disk) means I have peace of mind when I back-up my own passwords, and don't have to leave them in trust of a one-man business. Sorry, but that's just my personal opinion of the idea/site, maybe others will think otherwise. Stephen
  • 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.