Jump to content

phpzone

Members
  • Posts

    135
  • Joined

  • Last visited

    Never

Posts posted by phpzone

  1. You can use marquee if you wish, however to get it to work through the validator you would have to

    dynamically add the marquee with javascript:

     

    <script type="text/javascript">
    <!--
    window.onload = function()
    {
    
    marquee = document.createElement('div');
    marquee.setAttribute('id', 'mymarquee');
    marquee.innerHTML = '  <!-- INSERT YOUR MARQUEE MARKUP IN HERE -->';
    document.getElementById('marquee-placeholder').appendChild( marquee );
    
    
    }
    //-->
    </script>
    

     

    Put some code <div id="marquee-placeholder"><!-- // marquee --></div> in your page and the above code would add a child to this

    with the marquee content.

     

    Using this type of method you can get code to validate right up to XHTML 1.0 (possible 1.1)

  2.        print "<p>Your password reminder will be with your shortly. Thank-you.</p>";
    print "<meta http-equiv=\"refresh\" content=\"2;url=http://www.sitename.co.uk\">";
    

     

    You cannot do this.   A meta http-equiv should be in the top of your page, in the <head></head> section.

     

    However, I think you should be looking at using code such as:

     

    <?php
         exit( header('Location: http://www.sitename.co.uk') );
    ?>
    

     

    Note, you cannot send a header if you have printed _anything_ to the page.  So to avoid, turn output buffering on at

    the top of the page and then clear the buffer if you need to redirect:

     

    <?php
    ob_start();
    
    print <<<_HEADER
    Welcome to so and so site....
    _HEADER;
    
    //
    // do lookup for email address etc.
    //
    
    if ( $email_not_found )
    {
         ob_clean();
          exit( header('Location: http://www.sitename.co.uk/register') );
    }
    else
    {
      // do email stuff
      print <<<_THANKS
      Your password has been reset and a copy of the new password sent to your email address.
    _THANKS;
    }
    ?>
    

  3. Perhaps you need to add a "user_group" system as well, so that you can check what group a user is in and based

    on that ask them for the password again.

     

    You will need a way to check whether they have entered a password for a section already, perhaps again

    you could add a 'sections_auth' array into your $_SESSION and when they auth in a section, add it's ID in there.

  4. my opinions:

     

    -no one would care to see your latest version.

    -such static layout sites like this are not really used anymore, needs more fluidity

    -wasted space with huge header/huge padding within cells

    -nav tabs too big

     

    just my 2 cents.

     

    Appreciate the feedback.

     

    True, latest version part is a gimmick.

     

    I disagree that static layouts are not used, see the new bbc.co.uk.  I'm going for something that is like my wordpress site, which is in the same format.  However I was thinking of doing a switchable CSS template, so a more fliud design could be done too, point taken on board.

     

    Anyone else?

  5. Ummm..

     

    Backup... Download Ubuntu Studio... Install... Voila ;-)  Same OS at both side.

     

    I'm joking, but it is an option, you can dual boot.

     

    And also...

     

        Download install Eclipse (apt-get install eclipse)

        Download install Aptana and Aptana PHP Plugin (add to update sites on eclipse and download through eclipse update)

        Apache2... apt-get apache2

        PHP5.... apt-get php5

        etc. etc. etc. ...

       

  6. <?php
    
    $xmlstr = <<<_XML
    <?xml version="1.0"?>
    <Catalog>
    <Category>
    <Name>Business to Business</Name>
    <Site>
    	<Id>Creed</Id>
    	<PopularityRank>4366</PopularityRank>
    	<Description>A simple desc</Description>
    	<HasRecurringProducts>true</HasRecurringProducts>
    	<Commission>75</Commission>
    </Site>
    <Site>
    	<Id>Creed 2</Id>
    	<PopularityRank>5000</PopularityRank>
    	<Description>Another simple desc</Description>
    	<HasRecurringProducts>false</HasRecurringProducts>
    	<Commission>7400</Commission>
    </Site>
    </Category>
    </Catalog>
    _XML;
    
    $xml = simplexml_load_string( $xmlstr );
    
    $sites = $xml->xpath("/Catalog/Category/Site");
    
    foreach ( $sites as $site )
            {
    
    	echo "<p>{$site->Id} = {$site->Commission}</p>";
    
            }
    
    ?>
    

  7. Ok.  I don't see the reason for having to 'find' things.

     

    I've done this and usually on my sites I have a structure like:

     

    /images/

    /classes/

    /templates/

    header.php

    index.php

    config.php

    footer.php

     

    My can you not have a standard structure, keep your image.php in /images/ and your class in a

    folder?  Then have a variable in config.php that defines your BASE_PATH and use that?

  8. Then in Main.class.php you want to include pec.php?

     

    Ok... if your other file is always one directory up then the following....

     

    <?php

     

            require_once dirname(dirname(__FILE__)) . '/pec.php';

     

    ?>

     

    If it's anywhere on the system, I'm not 100% sure but you could use passthru and search with a system command:

     

    <?php

    $basepath = '/var/www/html';

    $result = passthru("find {$basepath} -name 'pec.php' -print");

    echo $result;

    ?>

     

     

  9. You must give your radio buttons the same name and then simply check $_POST['choice'] to get its value.

     

    In this case I would do:

     

    <input type="radio" name="choice" value="2500">1<BR>
    <input type="radio" name="choice" value="1500">2<br><br>
    <input type="radio" name="choice" value="1000">3<BR>
    <input type="radio" name="choice" value="500">4<br><br>
    <input type="radio" name="choice" value="250">5<br><br>
    

     

    You can then get the value: $choice = $_POST['choice']; which would give you 250, or 500, etc. etc.

     

    You can do the same with checkboxes, however you will then allow multiple choices, so you would suffix your HTML input name with []

    such as

     

    <input type="checkbox" name="choices[]" value="2500">1<BR>
    <input type="checkbox" name="choices[]" value="1500">2<br><br>
    <input type="checkbox" name="choices[]" value="1000">3<BR>
    <input type="checkbox" name="choices[]" value="500">4<br><br>
    <input type="checkbox" name="choices[]" value="250">5<br><br>
    

     

    You would have to process this postback like so:

     

    
          $multi_choices = $_POST['choices'];
          foreach( $multi_choices as $choice )
          {
                print <<<_MESSAGE
                <p>Use has chosen $choice</p>
    _MESSAGE
          }
    
    

     

    Hope this helps.

  10. $sql=mysql_query("SELECT teams.teamName, teams.Points, contacts.division FROM teams LEFT JOIN contacts ON teams.teamName = contacts.teamName WHERE contacts.division=1  ");
    
    while($row=mysql_fetch_array($sql)) {
       echo "Team: " . $row['teamName'] . " Points: " . $row['Points'] . "<br />";
    }
    

     

    Ideally you would have an ID field in that, eg. teamID which is an INT AUTO_INCREMENT so you can refer to the team by an ID

    number rather than name.  I'd also have your teams in one table, and the score in another and join on them, that is if you want to

    enter the points scored in a single game each team and then have other code to tot up the total anyway.

     

    For the form/database part you need to look through your teams and output an input box for each one.

     

    A useful feature of PHP is being able to name form inputs in a certain way so that you receive an array back like the following:

     

    <input type="text" name="points[1]" value="" />
    <input type="text" name="points[2]" value="" />
    <input type="text" name="points[3]" value="" />
    

     

    If that was put into a form and submitted you would be able to retrieve the points in PHP as an array and then you could

    use foreach to get them, as you loop you would use an SQL INSERT statement to insert the points into the database.

     

                $points = $_POST['points'];
                foreach( $points as $team_id=>$score )
                {
    
                     // create yourself a function that INSERTS to database, and call it like the following:
                     insert_team_points( $team_id, $score );
    
                }
    

     

    Your SQL statement would be something:

     

       function  insert_team_points( $team_id, $score )
       {
    
            // make sure we have numbers!
            $team_id = (int)$team_id;
            $score = (int)$score;
    
            $sql = "INSERT INTO score_table ( team_id, score ) VALUES ( $team_id, $score )";
            mysql_query( $sql ) or die ( mysql_error() . ": $sql " );
    
       }
    

     

    I hope these HINTS help.   I've deliberately not supplied a full solution, because its good to learn :-)

  11. I don't know why you can't use a database, but I don't want to be bored by office politics, this I agree :-)

     

    You need to see if there is any pattern to the structure of your 'B' document, look into perl regular expression

    and see if you can parse with Regular Expressions.

     

    Or, if you can't use a database but can use CSV files why not put the data in a CSV file? (Or would you

    call this a database too)

     

    Or, put the data into an XML file and parse that where required.

  12. Write a wrapper function and use the wrapper, something like:

    <?php
    
    function GetVariable( $name )
    {
    
        if ( isset( $_GET[ $name ] ) )
       {
    
              return $_GET[ $name ];
    
       }
       else
       {
               // whatever to do if it doesn't exist
       }
    
    }
    
    $name = GetVariable("username");
    
    ?>
    

     

    Obviously code in your $_POST/$_SERVER stuff etc. where required.

×
×
  • 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.