Advanced Search

Results 1 to 10 of 10

Thread: Specifiy what tags show what?

  1. #1
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Specifiy what tags show what?

    how do you specify if a tag is equal to say 5 and shows a piece of text, but still show that text until the tag is equal to say 10?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    How can a "tag" be equal to 5?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    I think you mean, instead of tag, if a variable is equal to 5?
    You might want to try:

    PHP Code:
    for($i 5$i <= 10$i++) { echo 'The variable is between 5 and 10!'; } 
    But, to be more specific to your situation in the code, can you provide more details?
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What's with that do?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Haha, sorry. I don't know what I was thinking.

    Changed.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  6. #6
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by alexjewell View Post
    But, to be more specific to your situation in the code, can you provide more details?
    ok, say:
    $code == "5";

    now, when the $code is equal to 5, i want it to print a piece of text, and i don't want that text to disappear until $code is equal to 10?

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    What's making it change?

    More info.... a lot more info.

    The word until seems to barely even apply to PHP. Though it's linear and it you could say "until" it reaches a certain point, that's practically unnoticable, certainly with the text changing. So... do you mean javascript?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Dec 2006
    Posts
    74
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i have this code: everytime someone visit the page it alters the counter number. now, when the $code is equal to 5, i want it to print a piece of text, and i don't want that text to disappear until $code is equal to 10?

    PHP Code:
    //set the count file 
    $counterfile "hits/" .$me"_count.dat"

    //check the file is readable 
    if(!($fp fopen($counterfile,"r"))) die ("cannot open counter file"); 

    //grab the value and increase by 1 
    $count = (int) fread($fp20); 
    fclose($fp); 
    $count++; 

    //show the result, write the new value and close the file 
    echo "document.write('$count');"
    $fp fopen($counterfile"w"); 
    fwrite($fp $count); 
    fclose($fp); 

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    if($code > 4 && $code < 10)
      print "a piece of text";
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by lankinator View Post
    PHP Code:
    //set the count file 
    $counterfile "hits/" .$me"_count.dat"

    //check the file is readable 
    if(!($fp fopen($counterfile,"r"))) die ("cannot open counter file"); 

    //grab the value and increase by 1 
    $count = (int) fread($fp20); 
    fclose($fp); 
    $count++; 

    //show the result, write the new value and close the file 
    echo "document.write('$count');"
    $fp fopen($counterfile"w"); 
    fwrite($fp $count); 
    fclose($fp); 
    This is liable to fail when deployed: the file isn't locked, so data can between reading the existing value and writing the new one. The whole process should be atomic (which isn't necessarily easy in PHP):

    PHP Code:
    $counterFilename "hits/{$me}_count.dat";
    $counterFormat '%u';

    if ((
    $counterFile fopen($counterFilename'r+'))) {
        if (
    flock($counterFileLOCK_EX)) {
            
    // In PHP 4:
            //     if (!fscanf($counterFile, $counterFormat, &$counter)) {
            
    if (!fscanf($counterFile$counterFormat$counter)) {
                
    $counter 0;
            }
            
    // I have no idea why you'd want the indirection of using client-side scripting to write
            // the value into the document. Seems pointless to me.
            
    echo ++$counter;
            
    rewind($counterFile);
            
    fprintf($counterFile$counterFormat$counter);
            
    flock($counterFileLOCK_UN);
        }
        
    fclose($counterFile);
    } else {
        
    // I would suggest something more robust than just quitting here. In fact, once the file was
        // created (which you'd have to do manually, at the moment), you'd have to do something very
        // wrong to have this opening operation fail.

    I can't test concurrency properly here as file locks are made at the process level on Windows, and Apache only runs one process under NT-based OSs. However, it should be safer, at least.
    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •