Web coding help please!

Want to just shoot the breeze? Forum 42 is the place!

Moderator: Moderators

sam fisher
Posts: 1093
Joined: Mon Apr 25, 2005 8:52 am

Post by sam fisher »

As long as '/'s aren't needed in the variables ;)
Image
Harshboy
Portablizer
Posts: 3610
Joined: Tue Oct 11, 2005 3:44 pm

Post by Harshboy »

If you do it in HTML i can help you. Plus, there are many resource sites. Would you like to do it in HTML?
bicostp
Moderator
Posts: 10491
Joined: Mon Mar 07, 2005 5:47 pm
Steam ID: bicostp
Location: Spamalot
Contact:

Post by bicostp »

Thanks, but if I was going to do it in HTML I would not have made this thread. ;) Using HTML would need a seperate page for every video, and that's no good!

About the variables; would handling it as a string work? Or maybe some other scripting language?

I'll have to look and see what some other similar scrips use I guess...
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

I suggest making a file with the links and titles of all videos. say in the format of URL|::|TITLE .
Then you could process it into an array of links/titles with this:

Code: Select all

<?php
$contents = file_get_contents('video_links.txt');
$array = explode('|::|', explode("\n", $contents));
$links = '<ul>';
for($i=0;$i<count($array['0']);$i++) {
$links .= '<li><a href="'.$array[$i]['0'].'">'.$array[$i]['1'].'</a></li>'."\n";
}
$links .= '</ul>';
?>
Don't go on that code only though, I'm sick right now so I'm not paying too much attention to it :P

Edit:
Oh yeah, you could also make the links file into an XML file. This would be even better :P
So, the XML file could be in a format like this:
<link>
<url>URL</url>
<title>TITLE</title>
</link>

Code: Select all

<?php
$contents = file_get_contents('video_links.xml');
preg_match_all('|<link>(.*)</link>|s', $contents, $videos);
foreach($videos['1'] as $var) {
preg_match_all('|<url>(.*)</url>(.+?)<title>(.*)</title>|s', $var, $array);
}
$links = '<ul>';
for($i=0;$i<count($array['0']);$i++) {
$links .= '<li><a href="'.$array['1'][$i].'">'.$array['3'][$i].'</a></li>'."\n";
}
$links .= '</ul>';
?>
bicostp
Moderator
Posts: 10491
Joined: Mon Mar 07, 2005 5:47 pm
Steam ID: bicostp
Location: Spamalot
Contact:

Post by bicostp »

*shifty eyes*

*bump*

Help is still requested, please.

Since PHP doesn't like foward slashes in variables, what about a setup such as this?

<img src="http://img48.imageshack.us/img48/4012/planb8yq.gif">

Basically each movie file is on its own page, but you navigate between them with a php page. This minimizes labor for updating (Just make the html page and upload it, instead of changing every page to update the menu.)
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

Actually, any character is fine in a variable as long as it's escaped. An easy way is to just tell the php processor not to go through the string to look for code, like this:

Code: Select all

$string = '$ / \ . " ` \' \\\\ ~';
in that, the only character that needed escaping is the ' (single quote), and the \\ (double backstroke).
bicostp
Moderator
Posts: 10491
Joined: Mon Mar 07, 2005 5:47 pm
Steam ID: bicostp
Location: Spamalot
Contact:

Post by bicostp »

So the first plan would work then? :?

(Sorry, you're talking to someone who knows basically nothing about PHP here! :lol:)
sam fisher
Posts: 1093
Joined: Mon Apr 25, 2005 8:52 am

Post by sam fisher »

I know nothing either. Just spongey told me before php variables don'l like '/'s. Oh well I guess I, and he was too!!! BLAME SPONGEY, am wrong.
Image
gannon
Moderator
Posts: 6974
Joined: Sun Apr 04, 2004 4:48 pm
Location: Near that one big lake
Contact:

Post by gannon »

The XML Data File (video_links.xml):

Code: Select all

<?xml version="1.0"?>
<link>
<title>The Forums</title>
<url><embed src="http://benheck.com" /></url>
<description>The Forums</description>
</link>
<link>
<title>Gannon.tk</title>
<url><object src="blahblahdlhald">
</object></url>
<description>Gannon.tk</description>
</link>
The PHP File:

Code: Select all

<?php
$contents = file_get_contents('video_links.xml');
preg_match_all('|<link>(.+?)</link>|s', $contents, $videos);
$links = '<ul id="links">';
for($i=0;$i<count($videos['1']);$i++) {
preg_match('|<title>(.*)</title>(.+?)<url>(.*)</url>(.+?)<description>(.*)</description>|s', $videos['1'][$i], $array);
$files[$i] = array('url'=>$array['3'], 'title'=>$array['1'], 'desc'=>$array['5']);
$links .= '<li><a href="?id='.$i.'">'.$files[$i]['title'].'</a></li>'."\n";
}
$links .= '</ul>';
$id = isset($_GET['id']) ? $_GET['id'] : '0';
?>
<html>
<title><?php echo $files[$id]['title']; ?></title>
<head>
<style type="text/css">
body {
background-color:#EEE;
}
#main {
padding: 10px;
border: solid black 1px;
width:80%;
min-height:350px;
}
#description {
padding: 10px;
border: solid black 1px;
width:80%;
min-height:78px;
}
#links {
padding: 10px;
border: solid black 1px;
list-style: none;
position: absolute;
top: 5px;
right: 5px;
width:15%;
min-height:350px;
}
</style>
</head>
<body>
<div id="main">
<?php echo $files[$id]['url']; ?>
</div>
<br />
<div id="description">
<?php echo $files[$id]['desc']; ?>
</div>
<?php echo $links; ?>
</body>
</html>
I think you can handle editing the html portion :P
SpongeBuell
Senior Member
Posts: 5190
Joined: Wed Apr 07, 2004 10:52 am
Location: Colorado
Contact:

Post by SpongeBuell »

sam fisher wrote:I know nothing either. Just spongey told me before php variables don'l like '/'s. Oh well I guess I, and he was too!!! BLAME SPONGEY, am wrong.
I must have been thinking of \'s or something, I don't think I've ever said that :?
Life of Brian wrote:
RYW wrote:RYW:

Rare
Yellow
Weasel
I'll be honest with you - I would have never guessed that.
bicostp
Moderator
Posts: 10491
Joined: Mon Mar 07, 2005 5:47 pm
Steam ID: bicostp
Location: Spamalot
Contact:

Post by bicostp »

Neat! That looks a lot better than <a href="http://bicostp.portablesofdoom.org/Stuf ... html">this monstrocity</a>! :lol:

I uploaded it <a href="http://bicostp.portablesofdoom.org/Stuf ... p">here</a>, in case anyone wants to see what all the green text does.

I changed some of the dimension code a bit to make it fit better in a smaller window on another copy (<a href="http://bicostp.portablesofdoom.org/Stuf ... layer2.php" target="_blank">Link</a>).

This is exactly what I was thinking of! Thanks :)
sam fisher
Posts: 1093
Joined: Mon Apr 25, 2005 8:52 am

Post by sam fisher »

Thats what you said when me doign that xbox website media page spongey.
Image
Post Reply