Jul 26, 2008

I Could Use A Little Help Here [resolved]

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

I Could Use A Little Help Here [resolved]

Inhuman
CODE
<?php



$listdir = "comics"; // Customizeable
$listid = $_GET['id']; // Leave this alone

/* This function is the one I've been using forever. It just goes and grabs
an alphabetical array of files in the specified directory. */

function getlist_alpha(&$afiles, $listdir) {
if (is_dir($listdir)) {
if ($thisdir = opendir($listdir)) {
while (($afile = readdir($thisdir)) !== false) {
if (!is_dir($afile) && preg_match("/.*\.(gif|jp(e)?g|png)/i", $afile)) {
$afiles[] = $afile;
}
}
closedir($thisdir);
return $afiles;
}
}
}

/* This function actually creates the strings to be put in the selection list. */

function printoptions($item1, $key, $listdir) {
if (strpos($item1, ".")) { $item1 = explode(".", $item1);
$item1 = $item1[0]; }
$ffile = "$listdir/$item1";
if ($item1 == $_GET['id']) echo "\n<option selected>"; else echo "\n<option>"; echo "$item1</option>";
}

/* This function sorts a collected array and then uses printoptions to make the list. */

function comiclist($listdir, $listid) {
echo "<center><form name=\"comiclist\">\n<select name=\"id\" id=\"id\">";
$alisting = getlist_alpha($listcomics, $listdir);
rsort($alisting);
array_walk($alisting, 'printoptions', $listdir);
echo "</select>\n<input type=\"submit\" value=\"Go\" action=\"selection.php\" method=\"get\">\n</form></center>";
}

comiclist($listdir, $listid);


?></p>
<div align="center">
<p><?php
$cdir = 'comics';
$getc = $_GET['id'];
$phpfile = $_SERVER['PHP_SELF'];

function check_zeros($num) {
$digits = 3;
$pad = strval(0);
$num = strval($num);

if (strlen($num) != $digits) {
$num = str_pad($num, $digits, $pad, STR_PAD_LEFT);
}
return $num;
}


function find_comic($idnum, $dir) {
if (is_dir($dir)) {
if ($cdir = opendir($dir)) {
if ($idnum != 'all') $idnum = check_zeros($idnum);
if ($idnum == 'all') $num = 0;
while (($file = readdir($cdir)) !== false) {
if ($file != '.' && $file != '..') {
if ($idnum != 'all') {
if (preg_match("/$idnum\.(gif|jp(e?)g|png)/i", $file)) {
$idnum = $file;
}
}
else if (preg_match("/.*\.(gif|jp(e?)g|png)/i", $file)) {
$num++;
}
}
}
}
closedir($cdir);
}
if ($idnum == 'all') return $num;
else return $idnum;
}



$max_comics = find_comic("all", $cdir);

if ($getc < 1 || $getc == NULL || $getc > $max_comics)
$getc = $max_comics;

if ($getc > 1)
$getp = $getc - 1;
else
$getp = NULL;

$getn = $getc + 1;
$cshow = find_comic($getc, $cdir);

echo "<img src=\"$cdir/$cshow\" border=\"0\" /><br>";

echo "<br><br>";

if ($getc > 2)
echo "<a href=\"$phpfile?id=1\"><img src=\"first.gif\" border=\"0\"></a>";

if ($getc > 1)
echo "<a href=\"$phpfile?id=$getp\"><img src=\"back.gif\" border=\"0\"></a>";

echo "<a href=\"MAKETHISYOURHOMEPAGEURL\"><img src=\"home.gif\" border=\"0\"></a>";

if ($getc < $max_comics)
echo "<a href=\"$phpfile?id=$getn\"><img src=\"next.gif\" border=\"0\"></a>";

if ($getc != $max_comics && $getc < $max_comics - 1)
echo "<a href=\"$phpfile?id=$max_comics\"><img src=\"newest.gif\" border=\"0\"></a>";
?>


Ok, I got this code from here and it's not workin right.

Screen cap...and yes, I do plan on changing the look of the site. tongue.gif

Ok, so what's going on with this bad larry?

 

 

 


Reply

sonesay
Where are you using this file? it looks like its just parsing it out. Are you testing it on a PHP enabled server? Make sure you save that file as a .php file because when I changed it to html to eheck I got the same output as your screenshot.

Reply

Inhuman
Well I'm trying to get this to work on my website...I installed Templates Express and I don't think it is...but then again, I'm new to php...and I have no idea how it works. dry.gif


Change to php? I'll try that.

Edit: Sonesay, I love you with mouth. It worked. Thanks a lot man. smile.gif


Mods, do whatever it is you do with threads that have expired their purpose.

Reply

truefusion
Topic is resolved.

Please PM any moderator to continue this discussion. Until then, this topic is closed.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : resolved


    Looking for I, Could, Use, A, Little, Help, Here, [resolved]

Searching Video's for I, Could, Use, A, Little, Help, Here, [resolved]
advertisement



I Could Use A Little Help Here [resolved]



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE