I'm creating a video site using PHP, and I want to insert video source code from a PHP URL.
For example, if I want to get Episode 1 from PHP, I want it like this:
example.com/player.php?=episode1
For Episode 2:
example.com/player.php?=episode2
I don't understand how to link all of the source pages with the main index page.
How can I accomplish this task?
Here's a way you could do it: Use a form on your homepage (index.html?) to select which video you want, and send it to player.php using a GET method. Then use the following on player.php:
<?php
$select = $_GET['select']; //This will be the number input for the video number
echo("<video><source src="episode$select.mp4"></video>"); //This will source the video named `episodeX.mp4`, where `X` is the select value from the form on `index.html`.
?>
Just ask if you need any additional clarification.
Related
I am trying to use preg_match or preg_match_all to get the cover art from https://www.discogs.com/Lady-Gaga-Chromatica/release/15386439
So far I've only been able to get the Discogs logo and the favicon.
Here is the code I am using, which yields two images, the logo of Discogs.com and the favicon:
<?php
$text = file_get_contents("https://www.discogs.com/Lady-Gaga-Chromatica/release/15386439");
preg_match_all('/<img.*>/',$text,$out);
print_r($out);
?>
Edit 1:
I was asked to copy the data I'm trying to collect the image from, this is a lot of data so I am not able to post it here. It would be best if you could look at https://www.discogs.com/Lady-Gaga-Chromatica/release/15386439 and isnpect source to see the data.
Edit 2:
I looked at the console and see a 400 Bad Request code. But if I print out $text from the previous code, I can get the whole page to load on my webpage so I don't get why I can't fetch just the images.
I need to read a text file on a server and display its content in a blog post on Blogger. The text file is a result of a simple download counter and contains a number. The problem is the Blogger does not support PHP codes in a post. My current solution is to use OBJECT tag to call PHP script that displays the text file content with ECHO. It works. But the result is displayed inside a small frame and I can't apply CSS style to it or align it properly with the existing text. Is there another way? I understand it can be done with AJAX call but my scripting knowledge is basic and I wouldn't know where to begin. Help would be appreciated.
To display the result in the blog I used this code:
<p>File test.zip downloaded
<object type="text/plain"
data="http://example.com/statistics.php?dname=test"
width="30" height="30"></object> times</p>
EDIT: I have tried to follow #Toni suggestion but it only leads to more questions. Looks like Ajax call is way beyond my current level of knowledge. Sorry and thank you again.
Here is what I'm currently trying. I have moved the text that goes with the counter inside PHP file so the script now returns a string like "file has been downloaded 8 times" instead of just number "8". Also instead of OBJECT tag I'm using IFRAME.
<iframe src="http://example.com/mystats.php?dname=test"
frameborder="0" border="0" cells pacing="0" height="30"></iframe>
The iframe seems to be easier to style. If I can't figure out how to find which CSS is applied to a blog post and how to apply it to iframe, I can at the minimum mimic the style by using similar font.
You can use javascript with your blogger web-site.
Using javascript on your web-page, you can invoke a GET request to your PHP code and get the data you want, to display it on your web-page.
Below, there are links, to help you with this task:
How to invoke GET request in vanilla JavaScript
Invoking GET with jQuery
Use JavaScript to alter text dynamically
I made it work with JavaScript! Here is how. Server side PHP script reads and echoes a text file inside document.write().
<?php
$varcontent = #file_get_contents('yourtextfile.txt');
echo 'document.write("'.$varcontent.'")';
?>
The resulting string looks like this:
document.write("your text file content here")
Inside the Blogger post add the JavaScript code with the PHP script file as a source:
<script type="text/javascript"
src="http://example.com/yourfile.php">
</script>
Done! The content of your text file is displayed and styled with your current CSS.
We have several pages generated using PHP on our website with the following titles (for example):
http://www.mysite.com/project/category/1
http://www.mysite.com/project/category/2
http://www.mysite.com/project/category/3
Each one is created dynamically with the same page layout with each showing a different database result depending on the predefined conditions.
I would like an image to be displayed at the top of the page for just one of the results, let's say for http://www.mysite.com/project/category/2 - how can I go about this?
The relevant code on our page is this:
$category=mysql_fetch_array(mysql_query("select * from project_category where project_category_id='".$project_category_id."'"));?>
If we go down the if statement route can you show an example of how to display an example image by modifying the above code to get me started?
I would probably make it a property (can be a as simple yes/no) in the database, and use the existing db-result to determine if the category has to display a page. Although this might seem overkill - I'd definitely pick this dynamic solution over a if ($categoryId == 2) { } solution any day. Keeps it dynamic and your code clean and generic.
In the end I opted for an if statement (as found here http://www.tizag.com/phpT/if.php).
The original code above was modified in the following way:
$category=mysql_fetch_array(mysql_query("select * from project_category where project_category_id='".$project_category_id."'"));
if ( $project_category_id == "2" ) {
echo '<img src="http://www.mywebsite.com/image.jpg" width="675" height="75" border="0" />';
}?>
I have some thumbnail images with its larger version.I placed the thumbnail images in a page.Now for link I just gave a link
<img src="thumbnail1.jpg>
but for this I have to make different pages for showing larger one.I want to give a link to show them in a single page.means whenever I will click the thumbnail it will open the larger one in a page with the same url but with its name like
imagegallery.php?news=images/largerimage1/13.jpg
imagegallery.php?news=images/largerimage1/14.jpg
so how to do that?
Pretty basic stuff, I suggest you get to read some PHP tutorials on the internet to get some knowledge on one thing and another.
The ?news= part in your URL is a parameter that can be read by PHP. This type is known as $_GET. To get this part you would need $_GET['news'] so if we'd use your first link and place this inside a script: echo $_GET['news']; the page would say images/largerimages1/13.jpg.
In order to get the image loaded on your website we need some simple steps, I'm changing the news parameter into image, that suits better for your script since it ain't news items:
<?php
// Define the path (used to see if an image exists)
$path = 'your/absolute/path/to/public_html/'; # or wwwroot or www folder
// First check if the parameter is not empty
if($_GET['image'] != "") {
// Then check if the file is valid
if(file_exists($path . $_GET['image'])) {
// If an image exists then display image
echo '<img src="'. $_GET['image'] . '" />;
}
}
?>
Below this script you can put all your thumbnails the way you want. Ofcourse, also for these thumbnails there are some automated options. But I strongly suggest you get a good look at the script above and some beginner PHP tutorials so you completely understand the example given. This still isn't the best method, but it's kicking you in the right direction.
if your imagegallery.php is in root of your domain, you can just add slash as a first char to links like this:
<img src="thumbnail1.jpg>
else you will have to write some php function which it returns BaseUrl of your web. Then it should looks like this:
<img src="thumbnail1.jpg>
maybe you can something like this,
Techincally, there is no thumbnail image, just a stretch version of the regular image
I don't understand which part you don't know how to do:
- the link part?
it should look like
<img src="thumbnail1.jpg>
- or the PHP part (the file called imagegallery.php)?
A webpage displaying a tabular info:
In thatt table one colunm name WEB_DETAILS has
For example:
db1:app1:filename
db2:app2:filename
db3:app3:filename
db4:app4:filename
It goes on....
Now i want to add a hyperlink for each(1 to end)...The condition here is I want to create a hyperlink which show file based on app1,app2,app4....(imagine that these are folder names)..
WEB_DETAILS:The info in this comes from a query which retrives:
In that i want to split and extract based on: the app name..How to do that?
Just do it like this:
db1
It sounds like you want to create a loop that will output these HTML links. For example
<?php
for($i=1;$i<5;$i++){
echo "<a href='app$i/filename'>db$i</a><br>";
}
?>
Although I don't know how that will fit into the context of your already existing table.