PHP - Including Video Inside Photo Slideshow
Hi, I have made picture slideshow and included many pictures for the slideshow but i also added a video, how to make it apear as it is not appearing. code: <?php //index.php $connect = mysqli_connect("dbhost", "dbuser", "dbpassword", "dbname"); function make_query($connect) { $query = "SELECT * FROM banner ORDER BY banner_id ASC"; $result = mysqli_query($connect, $query); return $result; } function make_slide_indicators($connect) { $output = ''; $count = 0; $result = make_query($connect); while($row = mysqli_fetch_array($result)) { if($count == 0) { $output .= ' <li data-target="#dynamic_slide_show" data-slide-to="'.$count.'" class="active"></li> '; } else { $output .= ' <li data-target="#dynamic_slide_show" data-slide-to="'.$count.'"></li> '; } $count = $count + 1; } return $output; } function make_slides($connect) { $output = ''; $count = 0; $result = make_query($connect); while($row = mysqli_fetch_array($result)) { if($count == 0) { $output .= '<div class="item active">'; } else { $output .= '<div class="item">'; } $output .= ' <img src="banner/'.$row["banner_image"].'" alt="'.$row["banner_title"].'" /> <div class="carousel-caption"> <h3>'.$row["banner_title"].'</h3> </div> </div> '; $count = $count + 1; } return $output; } ?> <!DOCTYPE html> <html> <head> <title>How to Make Dynamic Bootstrap Carousel with PHP</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <br /> <div class="container"> <h2 align="center">How to Make Dynamic Bootstrap Carousel with PHP</h2> <br /> <div id="dynamic_slide_show" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <?php echo make_slide_indicators($connect); ?> </ol> <div class="carousel-inner"> <?php echo make_slides($connect); ?> </div> <a class="left carousel-control" href="#dynamic_slide_show" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#dynamic_slide_show" data-slide="next"> <span class="glyphicon glyphicon-chevron-right"></span> <span class="sr-only">Next</span> </a> </div> </div> </body> </html> in the database i have the names of the photos from 1 to 5 then a video. The photos are shown but the video is not showing. Is there a way to include it in the slideshow? If not, is it possible to have a video player instead.
Thanks. Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=316454.0 The Script:
$desired_width = 110; if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); // Select the ID numbers of the last inserted images and store them inside an array. // Use the implode() function on the array to have a string of the ID numbers separated by commas. // Store the ID numbers in the "image_file_id" column of the "thread" table. $tqs = "SELECT `id` FROM `images` WHERE `image_file` IN ('$new_image_name')"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); $fetch_array = array(); $row = mysqli_fetch_array($tqr); $fetch_array[] = $row['id']; /* * This prints e.g.: Array ( [0] => 542 ) Array ( [0] => 543 ) Array ( [0] => 544 ) */ print_r($fetch_array); // Goes over to create the thumbnail images. $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/" . $new_image_name; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } }Hey, sorry that I am posting this darn image upload script again, I have this almost finished and I am not looking to ask more questions when it comes to this script specifically. With the script above I have that part where the script should store the ID numbers (the auto_increment column of the table) of the image files inside of one array and then the "implode()" function would get used on the array and then the ID numbers would get inserted into the "image_file_id" column of the "thread" table. As you can see at the above part the script prints the following: Array ( [0] => 542 ) Array ( [0] => 543 ) Array ( [0] => 544 )And I am looking to insert into the column of the table the following: 542, 543, 544I thought of re-writing the whole image upload script since this happens inside the for loop, though I thought maybe I could be having this done with the script as it is right now. Any suggestions on how to do this? Hello: I wanted to see if someone can help me figure out how to include data from my included navigation file. Meaning: I have this file called myNav.php (the database table storing this is "myUpcomingEvents"): Code: [Select] function spLeftMenu() { $spLeftMenu = " <div id=\"sideEvents\"> echo \" $mySideBarData; \"; </div> "; return $spLeftMenu; } I am trying to pull it into the Index.php page like this (the database table storing this is "myHome"): Code: [Select] <?php include('include/myConn.php'); include('include/myNav.php'); $query=mysql_query("SELECT * FROM myHome,myUpcomingEvents") or die("Could not get data from db: ".mysql_error()); while($result=mysql_fetch_array($query)) { $myPageData=$result['myPageData']; $mySideBarPageData=$result['mySideBarPageData']; } ?> <!DOCTYPE HTML> <html> <head></head> <body> <div id="siteContainer"> <div id="leftColumn"> <?php echo spLeftMenu(); ?> </div> <div id="mainContent"> <?php echo $myPageData; ?> </div> </div> </body> </html> Can't get it to work. It just writes out: Code: [Select] echo " ; "; Anyone know how I can get this to work? Thanks. Hi everyone.... I have a simple search.php And I want to include that in my html output page. I tried using <?php include ('search.php'); ?> Below is my HTML code which is part of a php file...what am I doing wrong here? Code: [Select] // Final Output echo <<<__HTML_END <html> <head> <title>Photography</title> </head> <body> <table width='100%' border='0' align='center' style='width: 100%;'> $result_final <?php include("search.php");?> </table> </body> </html> __HTML_END; Hi, I have a class: Code: [Select] class Toplist { public function get_article($id) { $id = (int) $id; $articles = array(); $query = $db->sql_query("SELECT * FROM `toplist` WHERE `id` = '$id'"); $result = $db->sql_fetchrowset($query); return $articles; } } and I get Quote Notice: Undefined variable: db in classToplist.php on line 11 Fatal error: Call to a member function sql_query() on a non-object in classToplist.php on line 11 the variable db is in ./models/config.php and it isn't working on the classToplist. I have a feeling that this happens because the config file is not a class. How can I fix this? Okay so we all know Code: [Select] <?php include "theme.html"; print: "Hello"; ?> Would output the theme and output hello at the bottom of the page, my question is, how do you position hello to go on the current theme? Thanks. Hey all, I've a problem with including of my pages. When I do choose lotto on index.php , I do get the page and also can choose how many roster I want. But I can't see my lotto results, because it does refresh to the index.php again. How can I fix this problem ? this is the code of index.php: Code: [Select] <?php echo '<table class="achtergrond" border="1">'; echo '<tr><td colspan="3">'; /* Keuzelijst tonen */ echo '<center><form action="'.$_SERVER['php_self'].'" method="POST"><select name="test">'; echo '<option selected>Kies een formulier</option></center>'; echo '<option value="1">Lotto</option>'; echo '<option value="2">Euromillions</option>'; echo '</select>'; echo '<button type="submit" name="knop">OK</button>'; echo '</form>'; echo '</td></tr>'; /* Als er op de knop gedrukt is , voer het lottoformulier uit*/ if(isset($_POST['knop'])) { echo '<tr><td>'; echo $waarde; /* variabel $waarde een waarde insteken via keuzelijst */ switch($_POST['test']) { case 1; include('formulieren/lotto.php'); case 2; include('formulieren/euromillions.php'); } echo '</td></tr>'; echo '</table>'; } ?> and this is the code of lotto.php: Code: [Select] <?php echo '<table class="achtergrond">'; echo '<tr><td colspan="3">'; /* Keuzelijst tonen */ echo '<center><form action="'.$_SERVER['php_self'].'" method="POST"><select name="lotto">'; echo '<option selected>Kies aantal rooster</option></center>'; echo '<option value="1">2 roosters</option>'; echo '<option value="2">4 roosters</option>'; echo '<option value="3">6 roosters</option>'; echo '<option value="4">8 roosters</option>'; echo '<option value="5">10 roosters</option>'; echo '<option value="6">12 roosters</option>'; echo '</select>'; echo '<button type="submit" name="knop1">OK</button>'; echo '</form>'; echo '</td></tr>'; /* Als er op de knop gedrukt is , voer het lottoformulier uit*/ if(isset($_POST['knop1'])) { /* variabel $waarde een waarde insteken via keuzelijst */ switch($_POST['lotto']) { case 0; $waarde2 = 0; break; case 1; $waarde2 = 1; break; case 2; $waarde2 = 2; break; case 3; $waarde2 = 3; break; case 4; $waarde2 = 4; break; case 5; $waarde2 = 5; break; case 6; $waarde2 = 6; break; }... I'm having trouble including my navigation bar in my web pages using PHP.
This is the script i have included in my web page, but it's not working.
<?php include("navbar.php"); navBar(); ?>This is the script in navbar.php enclosing my navigation bar. <? function navBar() { ?> NAVIGATION BAR <? } ?>Help is appreciated. Suppose you have a ENORMOUS library class where you have collected - perhaps - validation functions. Suppose you also have a small php script that you wish to use one of these validation functions in. So, you include the class. Is there a lot of "overhead" involved in including a huge class of which you use only one function? Hello everyone, I have a general question about something that I've been thinking about doing but have not tried yet. It involves including entire php pages rather than a short snippet of code. Here's my situation: I've created a website that caters to many different schools, each of which is assigned a sub-domain so that they have "their own" web site instead of going to one site and then clicking a link to get to their page. Every site is identical with the exception of a few images. The way I'm currently doing things is to upload every page of code into each folder the each website. Doing it this way, I'm using a lot of disk space and each time I edit one page of code, I have to upload that page to every folder in my directory. It's not too bad with only a few folders, but as more schools use my site, it could become a nightmare! What I'm thinking about doing is to upload all my pages to the parent directory, then on each page in my folders for the sub-domains just include the corresponding page in the parent directory. I will just keep the images for each sub-domain in the corresponding folder. For example, the actual code for the index page in each of my sub-domain folders would be this: Code: [Select] <?php include("../indexpage.inc.php"); ?> This way, I use less disk space and if I need to edit some code, I do it once, and upload it once to the parent directory, instead of having to upload it to each and every folder. Does anyone see any problem with doing this? Thanks for your opinion. Hi, Just a quick query. I call my db connection and configuration files on every script. I also have just made a functions script where i'm storing some functions except when i call the function, my script fails because of a missing database connection. But on the page that fails, i call the configuration files including the db connection at the start of the script. But when i get to where i include the function they are all on the same script so should it fail?? The page did work fine when the function was inbedded in the script. But as i'm using the function on a few pages, i thought it would be better practise and more efficent to just include the function on each page i need, rather than just copy and paste all the php in the required pages. Or do i have to declare the db connection inside the function page as well??? Thanks Hello everyone, This is a fairly simple question, but the explanation of the question isn't... I'll do my best. I have a site where my folders/sub-folders/files are arranged similar to this: _ Root Folder -| Root-IncludeFile1.php | Root-IncludeFile2.php | _ | Sub-Folder 1 -| Sub1-File1.php | |_Sub1-File2.php | _ | Sub-Folder 2 -| Sub2-File1.php | |_Sub2-File2.php | _ |_Sub-Folder 3 -| Sub3-IncludeFile1.php |_Sub3-IncludeFile2.php Hopefully that makes sense to everyone. Anyway, I know that to include a file that is in the root folder in file in a sub-folder, I can do this - include("../includefile1.php"); -but I'm trying to include a file that is in a sub folder in a file that is in another sub-folder. For example, I'm trying to include "Sub3-IncludeFile1.php" in "Sub-File1.php" I'm lost on this because I can't get it to work. I'm not getting any error messages except to say that the variables located in the file that should be included are not found. I've tried to do this: include("http://www.mysite.com/Sub-Folder3/Sub3-IncludeFile1.php"); and it doesn't work. Can someone please point me in the right direction? Thanks in advance for your help. Hi all, I've got two scripts for my website which I would like to display on one page, but what i've got is, The Menu on one php file, and the content on a different php file. Ive tryed the include, include_once, require, require_once, but for which ever one I use it just displace a blank page with nothing on it. Both of the files work on there on, but when I include the menu to the content page it just dont show anything. This is what ive tryed: <?php include ("crewtop.php"); if ($crewstuff->boss == $username || $crewstuff->coowner == $username || $crewstuff->underboss == $username){ ?> <table width='80%' align='center' class='table' cellpadding='0' cellspacing='0' border='1'> <tr> <td class='header' colspan='4' align='center'>Current Crew Members</td> </tr> <tr> <td class='omg' align='center' width='25%'>Username</td><td class='omg' align='center' width='25%'>Rep</td><td class='omg' align='center' width='25%'>Rank</td><td class='omg' width='25%' align='center'>Kick</td> </tr> This seems a easy thing to sort, just I carnt see why it isnt displaying the other file.. Anyone see why? Thanks. (if more code is needed i'll display more) Is it possible to include $_SERVER['REMOTE_ADDR'] in Code: [Select] mysql_query("INSERT INTO ips VALUES (null, canitgohere)"); Hey all. I have a form with inputs "menuitem[]" array. Upon no user input to one of these fields I want to set a variable error and include the form generation page. Is my following code a feasible way to do this? foreach($_POST['menuitem'] as $value) { if(!isset($value) || $value == "") { $emptyvalue = TRUE; } } if ($emptyvalue) { $erroralert = "You must fill in all the form fields! Please try again!"; include "views/addmenus.php"; exit(); } If works but just a bit unsure about it. Cheers! hi i want to include session so that attendance.php can't be acess directly.. Hi,
Just wondering if it's possible to get the dynamic part of the URL with the GET method?
I'm getting the address of the URL to add to a database when a user reports an error on that page;
<?php $actual_link = $_SERVER['PHP_SELF'];?>But I've noticed the if the url is for example "profile.php?username=someone" then it is only getting "profile.php". I have a class which loads language files and adds the content(which is an array) into a phrases array. It's performed perfectly when i included common_lang.php and login_lang.php. However when i include common_lang.php and profiles_lang.php something weird happens. I have a blank space at the top of the profile pages. And firebug reports that the content of <head> is now empty and its shifted all of it to the <body>. Like i say this only happens when including profiles_lang.php but works with other files like login_lang.php. The content of each language file is the same apart from the data in the array. $l = array( 'USERNAME' => 'Username', ); this is the language class which is being called in profiles.php like Asf_Language::loadFile('profiles'); The same call is used in other pages replacing 'profiles' with the name of the language file to call. <?php /* ASF A Simple Forum * (c) ASF A Simple Forum 2010 - 2011 * * @licence http://www.asimpleforum.co.uk/licence * * $page includes/languageClass.php * $author Carl Markham * $created 14/06/2011 */ class Asf_Language { public static $lang; public static $phrases = array(); public static $loaded_langs = array(); public function __construct($default) { $this->setLang($default); self::loadFile('common'); } public static function setLang($lang) { self::$lang = $lang; } public static function getLang() { return $lang; } public static function loadFile($file) { $include = dirname(dirname(dirname(__FILE__))).'/languages/'.self::$lang.'/'.$file.'_lang.php'; if(file_exists($include)) { include($include); self::$loaded_langs[] = $file; foreach($l as $key => $val) { self::$phrases[$key] = $val; } } else { echo 'File '.$include.' does not exist'; } return; } public static function getLoadedLanguages() { return implode(', ',self::$loaded_langs); } } Anyone have any ideas why the head is being emptied when this file is being included? How do i include a php variable inside the body of my email i've tried a number of things and have had no success here is my code a the moment <? FunCtion gEtRAnDomString($lEngth = 4) { $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $vAliDChArNumBEr = strlEn($vAliDChArACtErs); $rEsult = ""; For ($i = 0; $i < $lEngth; $i++) { $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1); $rEsult .= $vAliDChArACtErs[$inDEx]; } rEturn $rEsult; } FunCtion gEtRAnDomString1($lEngth = 6) { $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $vAliDChArNumBEr = strlEn($vAliDChArACtErs); $rEsult = ""; For ($i = 0; $i < $lEngth; $i++) { $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1); $rEsult .= $vAliDChArACtErs[$inDEx]; } rEturn $rEsult; } FunCtion gEtRAnDomString2($lEngth = 4) { $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $vAliDChArNumBEr = strlEn($vAliDChArACtErs); $rEsult = ""; For ($i = 0; $i < $lEngth; $i++) { $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1); $rEsult .= $vAliDChArACtErs[$inDEx]; } rEturn $rEsult; } FunCtion gEtRAnDomString3($lEngth = 6) { $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $vAliDChArNumBEr = strlEn($vAliDChArACtErs); $rEsult = ""; For ($i = 0; $i < $lEngth; $i++) { $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1); $rEsult .= $vAliDChArACtErs[$inDEx]; } rEturn $rEsult; } FunCtion gEtRAnDomString4($lEngth = 4) { $vAliDChArACtErs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $vAliDChArNumBEr = strlEn($vAliDChArACtErs); $rEsult = ""; For ($i = 0; $i < $lEngth; $i++) { $inDEx = mt_rAnD(0, $vAliDChArNumBEr - 1); $rEsult .= $vAliDChArACtErs[$inDEx]; } rEturn $rEsult; } $code = " gEtRAnDomString() - gEtRAnDomString1() - gEtRAnDomString2() - gEtRAnDomString3() - gEtRAnDomString4() "; //change this to your email. $to = "n**********"; $from = "na*******y_19*******co.uk"; $subject = "Code"; $message = "Your order code is: $code "; $headers .= "From: $from"; mail($to, $subject, $message, $headers); echo "Message has been sent....!"; ?> If anyone can help it will be great Thanks, Blink359 |