Jump to content

stephenk

Members
  • Posts

    62
  • Joined

  • Last visited

    Never

Posts posted by stephenk

  1. 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

  2. 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

  3. <?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

  4. 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

  5. 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

  6. 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!

  7. 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!!

  8. 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

  9. 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
  10. 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 &amp;, 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

  11. 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!
  12. [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
  13. 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
×
×
  • 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.