jnerotrix Posted December 4, 2008 Share Posted December 4, 2008 Ok I am making a code to get more youtube views And i need it so in a form you set number of Videos to be displayed in number of seconds So The Form Would Look Like This <table border="1"> <tr> <td>(Number)<input type="text" name="times" value="10"> of Times to Display Video in <input type="text" name="reloadtime" value="5">(Seconds) </td> </tr> </table> So if The Number is Set to 10 Which is default Then it displays this code 10 times echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; and if its set to 20 then it displays that code 20 times is this possible Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/ Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 Do you want it to display like that code 20 times every x seconds? If so, javascript would be the way to set this up, not necessarily ajax but if you code in the JScript it should work. Also the slee might work, but the page would not finish loading until all the items have been displayed and chances are the browser would time out. Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706252 Share on other sites More sharing options...
jnerotrix Posted December 4, 2008 Author Share Posted December 4, 2008 no it displays the code 20 times in Specified place on page and the x Seconds is just a meta refresh thats not the problem its the displaying the code x amount of times so it generates the code again and again Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706257 Share on other sites More sharing options...
chronister Posted December 4, 2008 Share Posted December 4, 2008 Sounds like you need a simple loop to take the number entered in the input and then display the object tag X number of times. Very simple task. Take a look at while loops in the php manual. Nate Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706258 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 <?php $numTimes = 10; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; } ?> Will display it 10 times on the page. Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706263 Share on other sites More sharing options...
jnerotrix Posted December 4, 2008 Author Share Posted December 4, 2008 So Would this work <?php $numTimes = $_POST['times']; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706271 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 So Would this work <?php $numTimes = $_POST['times']; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; } ?> Should, although I would do this <?php $numTimes = (isset($_POST['times']) && is_numeric($_POST['times']))?$_POST['times']:10; for ($i=0; $i < $numTimes; $i++) { echo '<object width="$setwidth" height="$setheight""><param name="movie" value="http://www.youtube.com/v/$url&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/$url&hl=en&fs=1$autoplay" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="$allowfullscreen" width="$setwidth" height="$setheight"></embed></object>'; } ?> That way if it isset and is numeric it is set to that value, else it is defaulted to 10. Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706275 Share on other sites More sharing options...
jnerotrix Posted December 4, 2008 Author Share Posted December 4, 2008 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/135568-solved-create-number-of-times-to-display/#findComment-706285 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.