TONYTOC Posted July 5, 2009 Share Posted July 5, 2009 I have a page that pulls up all the files in a folder for download. My problem is 2 fold. First i dont know how to apply a text style i have to the results (they are purple and i want them white) and second i have no idea how make them into columns. here is my syle: <style type="text/css"> <!-- .downloadtext { font-family: Arial, Helvetica, sans-serif; font-size: medium; font-style: normal; color: #FFF; text-decoration: none; text-align: left; } And here is what i have to pull up the files: <?php $count = 0; if ($handle = opendir('demos')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") {$count++; print("<a href=\"/demos/".$file."\">".$file."</a><br />\n"); } } closedir($handle); } ?> I have tried..... print("<a href=\"/demos/".$file."\"><span class="downloadtext">".$file."</a><br />\n");but of course it does not work. My vision was to have the files in 4 rows of 20 on a single page (i have not went far enough to change font size(what i have will be to big eventually). Very very new to this so if my question sounds like gibberish just let me know. Here is what i get with the above code: Quote Link to comment Share on other sites More sharing options...
shergold Posted July 5, 2009 Share Posted July 5, 2009 to link the css stylesheet: echo "<LINK REL="style sheet" TYPE="text/css" HREF="mysheet.css" TITLE= "Default"> "; Quote Link to comment Share on other sites More sharing options...
shergold Posted July 5, 2009 Share Posted July 5, 2009 is that what you was looking for? sorry if not im a noob also. Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 Thx for help but unfortunately i could not get that to work. Quote Link to comment Share on other sites More sharing options...
Dekthro Posted July 6, 2009 Share Posted July 6, 2009 Try echo "<LINK REL='style sheet' TYPE='text/css' HREF='mysheet.css' TITLE='Default'> "; Using single quotes inside the echo instead of double. Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 Hmm maybe im not applying this correctly. First i only have the style setup in this particular .php and do not have it in my style.css. Do i need to put this syle into my .css page or is there a way to just reference from inside this .php. Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 ok i finally got it. print("<a href=\"/demos/".$file."\"><span class='downloadtext'>".$file."</a><br />\n"); Thx for the ' vs " tip. Now i just need to know how to list them into 4 columns. All the help on columns is geared for table querys which i cant seem to apply to my situation. Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 using your old code <?php $count = 1; if ($handle = opendir('demos')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { print("<a href=\"/demos/".$file."\"><span class='downloadtext'>".$file."</a> - \n"); $count++; if ($count==4){ print("<br />"); $count=1; }//end if }//end if } closedir($handle); } ?> ugly, but it'll work Quote Link to comment Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 No need to use the span... <?php $count = 1; if ($handle = opendir('demos')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { print('<a href="/demos/' . $file . '" class="downloadtext">' . $file . "</a> - \n"); $count++; if ($count==4){ print("\n<br />\n\n"); $count=1; }//end if }//end if } closedir($handle); } ?> Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 Are you trying to make me look like an underachiever Andy-H ? Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 Ok cool thats getting me closer. That only puts the results into groups of 4 straight down. What im wanting to do is have them in rows of 20 and 4 columns. Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 link? Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 right now its on..http://192.168.1.178/ and then click on match demos link edit:thx for that tip Andy-H, that got rid of those unsightly purple lines that show up under the text once clicked on. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 Are you trying to make me look like an underachiever Andy-H ? lol I wouldn't do that You tried to access the address http://192.168.1.178/ which is currently unavailable. Please make sure that the Web address (URL) is correctly spelled and punctuated, then try reloading the page. Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 Are you trying to make me look like an underachiever Andy-H ? lol I wouldn't do that hmm... http://www.phpfreaks.com/forums/index.php/topic,259392.0.html also, that link takes me no where.. Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 sorry about that try..http://24.31.188.173/ Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 it seems that your space isnt wide enough for 4 files accross. Have you considered just putting say, "Download" inside of your <a></a> tags instead of the full filename? or maybe substr it a bit? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 <?php $count = 0; if ($handle = opendir('demos')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo '<a href="/demos/' . $file . '" class="downloadtext">' . substr($file, 0, strpos($file, '.')) . "</a> - "; $count++; if ($count % 4 === 0){ echo " <br /> "; }//end if }//end if } closedir($handle); } ?> That work? Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 I was trying to get him to do it himself.... :| Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 I really need to leave the file names intact as its the best way to find the match you are looking for since they are date and time stamped. As far as size being an issue, i can change the text size to anything. Are you saying that if i reduce the size then the script you gave me should list them properly? Ill play around with that and see what happens. Your guys input is greatly appreciated. edit: crap you guys are too fast. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 That script will just get rid of the extention, Might need to add -1 to the strpos, cant remember. Also, looking at the source it adds a <br /> After every link, using the modulus operator may or may not make the difference but its worth a shot? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted July 6, 2009 Share Posted July 6, 2009 <?php $count = 0; if ($handle = opendir('demos')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo '<a href="/demos/' . $file . '" class="downloadtext">' . substr($file, 10, strpos($file, '.')) . "</a> - "; $count++; if ($count % 4 === 0){ echo " <br /> "; }//end if }//end if } closedir($handle); } ?> Try that, it will remove the [-TOC-]CTF- part Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 here goes <?php $count = 0; if ($handle = opendir('demos')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $string=substr($file,11,-14); $string=str_replace('_','/',$string); echo '<a href="/demos/' . $file . '" class="downloadtext">' . $string . "</a> - "; $count++; if ($count % 4 === 0){ echo " <br /> "; }//end if }//end if } closedir($handle); } ?> and this will make the useless hour min sec go away, as well as those unsightly underscores, just play around with the negative number if u wanna keep the hour/min/sec Quote Link to comment Share on other sites More sharing options...
seventheyejosh Posted July 6, 2009 Share Posted July 6, 2009 ANNNNDDDD u can add this: to make the date customizeable: $string=substr($file,11,-14); $string=str_replace('_','/',$string); $string=strtotime($string); $string=date('F D Y',$string); // or watever format for date u want (use php.net http://us3.php.net/manual/en/function.date.php watever u put in the ' ' of the date will show based off the values at php.net Quote Link to comment Share on other sites More sharing options...
TONYTOC Posted July 6, 2009 Author Share Posted July 6, 2009 Thanks guys! I believe im all setup now thanks to you all. I would have never gotten there on my own. Those time stamps are when the actual match was recorded on the server so i had to leave them in there. I changed it to 3 columns to keep the files fairly legible. Thanks again. Quote Link to comment 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.