smoseley
-
Posts
433 -
Joined
-
Last visited
Posts posted by smoseley
-
-
$Result = array_merge($Array1, $Array2);
-
By the way, in answer to this question:
Should you create a separate JS file for something that will be used one time?I know that was probably rhetorical, but the answer can be yes. If your script is significant in size, and the page using it can be visited multiple times per visitor, then there's a benefit to creating an external script for it. I've done this many, many times.
-
Doesn't depend on the script. If you use a load-event handler, the script can go anywhere. If you put it at the end of the <body>, you don't need a load-event handler. That's pretty much that.
As for "best practices", I said it "should" go in the <head> because some older browsers (much older) don't support <script> blocks in the <body>. I was trying to illustrate that "best practices" are silly when then end-result has essentially no effect on your users. What's "best" is what works, while still being valid code.
-
It's exactly what I just said. That means "if date & time of the game is more than one hour in the future, return 1... otherwise return 0..." and that formula is aliased "AS" the pseudo-column "active".
-
"active" means the game hasn't started yet, and won't start within the next hour.
-
It's best practice.
It's also best practice to put all JavaScript in your <head> and not at the bottom of the page.
-
Likely his .ini isn't set to use short-tags. He'll need to either enable that, or use
var timeleft = <?php echo $timeleft; ?>;
Likely not That's very rare. Likely the issue is he just doesn't understand how JS console works.
-
Yes, it's a little messy messy.
It's a best practice to split separate operations onto separate lines of code, e.g.:
$company_url = get_post_meta($post->ID, '_CompanyURL', true); if (!is_null($company_url)) { $company_url = esc_url($company_url); //more stuff }
-
I can't recommend a book. Look on Amazon for highly rated books.
My code is logging to the console. If you hit F12 in a console-enabled browser, and click the console tab, you'll see the output.
-
By the way here's the answer to your last question:
<?php // Some code $timeLeft = 300; ?> <script type="text/javascript"> var timeLeft = <?=$timeLeft?>; // 5 minutes var timer = window.setInterval(function() { timeLeft--; var minutesLeft = Math.floor(timeLeft / 60); var secondsLeft = timeLeft % 60; console.log('Time left: ' + minutesLeft + ':' + secondsLeft); if (timeLeft == 0) { window.clearInterval(timer); // do some ajax thing } }, 1000); </script>
But of course, your next question will be...
-
If my snippet didn't fully answer your "little problem" (and then some), I'm afraid you don't have enough knowledge to build the game you want to make.
I suggest you buy books on PHP & Javascript and do some reading.
Cheers!
-
var timeLeft = 300; // 5 minutes var timer = window.setInterval(function() { timeLeft--; var minutesLeft = Math.floor(timeLeft / 60); var secondsLeft = timeLeft % 60; console.log('Time left: ' + minutesLeft + ':' + secondsLeft); if (timeLeft == 0) { window.clearInterval(timer); // do some ajax thing } }, 1000);
-
Nice try smoseley, but $this->menu_array is still undefined.
Good point. But it's not supposed to be defined. He seems to want to reference $menu_array (param). I got one, guess I missed one.
-
class Menu { private $newmenu; private $menu; public function __construct($menu_array, $index, $select = null){ //Get Text for Links from Keys of Array $menu_text = array_keys($menu_array); // produce and output the correct menu $i=0; if(isset($select) && $select!=null){ $this->newmenu="<select>"; } foreach(array_values($this->menu_array) as $link_option){ $this->newmenu.=$this->menu; $i++; } if(isset($select) && $select!=null){ $this->newmenu.="</select>"; } } public function generateTopMenu(){ $this->menu='<a href="'.$link_option.'">'; $this->menu.=$menu_text[$i]; $this->menu.='</a> '; } public function generateSearchMenu(){ $this->menu.='<option value="'.$search_text[$i].'" >'.$search_item.'</option>'."\n"; } public function returnMenu(){ return $this->newmenu; } }
-
I tried that and it doesn't work, although I thought it might when I tried it on my own this morning.
Drummin' still in the lead...
Debbie
Ok, here's another shot at it:
dt, dd { display: block; float: none; clear: both; min-height: 1em; margin: 0 0 2px; padding: 0; } dt { font-weight: bold; } dd { margin-left: 20px; }
Of course, the isn't a bad idea. I'd probably go with that myself.
-
Ol, let's lose the apostrophe. escape some characters, and simplify it a bit:
preg_match("/^[\\w\\d\\-\\.\\\$:%,!]+\$/", $string)
-
Escape the ".":
preg_match("~^[-a-z0-9_:%$'\\.,!]+$~i", $string)
-
Simple CSS bug... just make your css something like:
dt { display: block; } dd { display: block; padding: 0; margin: 0 0 2px 20px; }
And done...
-
Did you put that javascript code at the bottom of the page? And it needs to be wrapped in
$(document).ready(function(){
//your code here
});
If it's at the bottom of the page, it doesn't necessarily need a window.onload (document-ready) event.
-
position: absolute;
this will only work effectivly if you've set
*{position: relative;}
How do you figure? Did you read the OP?
-
position: absolute;
-
show your php and your data.
-
This will tell you what's failing:
$result = mysql_query($query) or die(mysql_error());
-
Do you have a database with a table named dragdrop? Or is that just from the example?
Combining 2 arrays
in PHP Coding Help
Posted
Oops, missed the overlap. This'll work (though a bit sloppy):