stephenk
-
Posts
62 -
Joined
-
Last visited
Never
Posts posted by stephenk
-
-
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
-
Hello.
I am available to take on small to medium projects. I am a very honest and reliable person located in the UK (but very happy to work with international clients).
I have around 3 years experience working with PHP and MySQL, 4 years with CSS and 6 years with HTML. I have had 8-10 happy customers from this forum (small programming jobs), but have also worked on full websites, creating control panels, etc. for administrators.
I am frequently available on MSN Messenger, and of course can be contacted by email.
Please get in touch if you would like to work with me!
Email/MSN: me <AT> stephenknox <dot> com
Many thanks,
Stephen
-
<?php if($a = "1" or $a = "2" or $a="3") {} else {} ?>
That will always return true. Use == for comparison not a single =
Yeah, well spotted, I usually do that, but the code I quickly wrote out was just for simplicity, not code from my script
Like wise you could do this:
<?php if(ereg("1|2|3", $a)) {} else {} ?> or <?php if(ereg("([1-3])", $a)) {} else {} ?>
Should work too.
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
-
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?
-
-
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
-
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
-
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
-
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!
-
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
-
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!
-
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
-
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!!
-
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
-
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 -
pixy: I'm not font of the background myself - is there any colour/pattern you would suggest?
P.S. What is your avatar gif showing? ???
Thanks for the comments.
Stephen
Edit: Background lightened - much better thanks. -
Thanks for that. I am familiar with styling lists, however I dont really understand the advantage of it.
Currently I have a simple <div class='menu'><a>Link</a><a>Link2</a></div> etc, so im free to style as I like through css. Maybe you could explain?
I got the location page validated now, its strange that google doesnt produce the links with &, thanks for the help.
Thats my 2nd fully accessible/tableless site I've made now, so hopefully I'll be able to get a few more jobs.
Regards,
Stephen
-
AndyB:
Thanks for the tip regarding the google map. I validated it on another site I made, but couldn't remember how.
Regarding payment, I'm good friends with the shop owner, so that isn't a problem - he seems very happy with the site, the google map amazed him when he was able to switch to satelite mode and view a city he is visiting on Monday, not much mention of the control panel that took 60% of the time to make!
However I still don't know how much my design and PHP skills are worth. I will be getting around $450-500 for that site. Is that cheap/just right/or is the shop owner offering too much?
Regards,
Stephen
P.S. I didn't actually mention that I would like some critique for the site please! -
[url=http://www.classicurbanwear.net]http://www.classicurbanwear.net[/url]
I've almost completed Classic Urban Wear. It's finished apart from a bit of content here and there.
All pages except the location one are w3 valid, the google map seems to be throwing up the errors.
I made this site for a man I know in town who owns the shop and through a password protected control panel, he can add/delete brands, Collection pictures, events and modify the information box up top.
There is an RSS feed for the events.
The site is all css and divs and made in around 20 hours.
Can anyone give some guidance on how much $$ that site would be worth? I know this one will go cheap, but it's for future projects.
Thanks for any comments,
Stephen -
Thanks for the help. Im going to have to just put the actual code in the file and use an include to get the private bits.
Regards
Stephen -
Thanks for your help.
Is there a function to include the actual code and not just the output. I can't place the actual code in the script for security reasons, hence the reason Im using includes.
Regards,
Stephen -
Hi,
I have a simple script uploaded to mydomain.com/test.php containing the following:
[code]<?php
setcookie("tester");
echo "tester";
?>[/code]
I then have a file hosted locally with the following code:
[code]<?php
include "http://www.mydomain.com/test.php";
?>[/code]
When I run the local file, the echo text is shown, however the cookie isn't set. If I place test.php locally also, the include works as expected.
Thanks for any help,
Stephen -
I mentioned in another thread that notifications don't seem to be working correctly. I may only get notification for 1 out of 10 new topics in the freelancing forum.
Stephen -
I have re-subscribed. See above :)
Stephen
Counting table rows
in Javascript Help
Posted
Excellent, thanks very much, now working!
Stephen