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?
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?
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!
I think you mean, instead of tag, if a variable is equal to 5?
You might want to try:
But, to be more specific to your situation in the code, can you provide more details?PHP Code:for($i = 5; $i <= 10; $i++) { echo 'The variable is between 5 and 10!'; }
Thou com'st in such a questionable shape
Hamlet, Act 1, Scene 4
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!
Haha, sorry. I don't know what I was thinking.
Changed.
Thou com'st in such a questionable shape
Hamlet, Act 1, Scene 4
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
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($fp, 20);
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);
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!
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):
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.PHP Code:$counterFilename = "hits/{$me}_count.dat";
$counterFormat = '%u';
if (($counterFile = fopen($counterFilename, 'r+'))) {
if (flock($counterFile, LOCK_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($counterFile, LOCK_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.
}
Mike
Bookmarks