Jump to content

yoshida

Members
  • Posts

    293
  • Joined

  • Last visited

Posts posted by yoshida

  1. Resolved.

    <?php$folder=$_GET['folder'];$path="imgs/small/$folder";$_SESSION['folder']=$folder;//Open images directory$dir = opendir("$path");$i=1;//List files in images directorywhile (($file = readdir($dir)) !== false) {	$image[$i] = "$file";	$i++;}sort ($image);$i=1;echo "<div id=tekst><table cellspacing=20 align=center>";foreach ($image as $key => $file) {	if ($file == "." || $file == ".." || $file == "Thumbs.db") {	}	else {		if ($i == '1') {			echo "<tr><td><a href=index.php?pageid=foto&img=$file><img src=$path/$file border=0></a>";		}		if ($i == '2') {			echo "<td><a href=index.php?pageid=foto&img=$file><img src=$path/$file border=0></a></tr>";			$i=0;		}		$i++;	}}closedir($dir);?>

    JSG, I'll look into your alternative syntax. It looks more refined to me. I'll look into is_dir as well.Thanks guys

  2. You might be better off checking for the "." and ".." as filenames and discarding them instead of the method you use. What happens if you have a sub-directory in there? Might check for that, too. Check out the php.net for the is_dir function.
    Thanks, I'll try that. I'll let you know if it worked.EDIT: the thing with eliminating "." and ".." worked flawlesly. (bug fixed, you won't notice it anymore) The image order doesn't matter that much to me yet, but when it does I'll have to look into fetching the file list into an array and sort that. (although I don't really think you can do that without re-loading the page at least once)FIXED PORTION:
    if ($file == "." || $file == "..") {}else {	if ($i == '1') {		echo "<tr><td><a href=index.php?pageid=foto&img=$file><img src=$img width=300 border=0></a>";	}	if ($i == '2') {		echo "<td><a href=index.php?pageid=foto&img=$file><img src=$img width=300 border=0></a></tr>";		$i=0;	}	$i++;}

  3. Recently I've been trying to write a script to get pictures to show in a table. I've been doing well up to now (here's it).

    if ($pageid == 'fotos') {		$path="fotos/klein";		//Open images directory	$dir = opendir("$path");	$i=1;	//List files in images directory	echo "<div id=tekst><table cellspacing=20 align=center>";	while (($file = readdir($dir)) !== false) {		$img="$path/$file";		if ($i == '3') {			echo "<tr><td><a href=index.php?pageid=foto&img=$file><img src=$img width=300 border=0></a>";		}		if ($i == '4') {			echo "<td><a href=index.php?pageid=foto&img=$file><img src=$img width=300 border=0></a></tr>";			$i=2;		}		$i++;	}	echo "</table></div>";	closedir($dir);}if ($pageid == 'foto') {	$img=$_GET['img'];	echo "<div id=tekst><img src=fotos/$img border=0 width=100%>";	echo "<p align=center><a href=index.php?pageid=fotos>Terug</a></p></div>";}

    As you notice I set up a loop in which the first two attempts bounce. That's to stop the 'this folder' and 'previous folder' (./ and ../) from trying to show as an image. It works for my localhost, everything shows in alphabetical order.Once I upload the stuff, this (fixed) happens (scroll down). The image order is messed up. Instead of being sorted by filename, it's sorted by apperently nothing. I'm stuck here, what should I do? Does anyone know an alternative approach? Best thing would be to store the pathnames in a database and have them sorted and echoed that way, but that's a magic bullet I'm not intending to fire (yet).Anyway, help appreciated.

  4. I use html code for my menu, and store it into a MySQL database. It's loaded as one of the site's main elements and can be edited. I use the same content management system to update and create most parts of the site (content manager is restricted and hidden).

  5. Cracked it! (Almost...)

    <?php$path=imgs;//Open images directory$dir = opendir("$path");//List files in images directorywhile (($file = readdir($dir)) !== false)  {  echo "<img src=$path\\$file>";  }  closedir($dir);?>

    All I need to get rid off is 'false' images (<img src=imgs\.><img src=imgs\..>).

  6. If you want to implement the form and the handler in one script, let the handler check wether the submit button on the form has been clicked (else display the handler).Very roughly:if (submit has been clicked) { execute handler;} else { display form;}at least that's how I do this.If you already use mysql, you may want to create a database for all recepients, and let the handler check the number of database entries and 'loop' the handler that many times. I don't have the time to explain it in detail, but this is how I'd do it.Don't forget to add a notifier at the end of the handler, with a link to the homepage.

  7. Tried something very similar, but all I got was a blank screen when I enclosed the three rules (imagenumber, header and readfile)The part where you don't have a clue is the relevant part... lol :)

  8. That's not how it works... there's lots of ways to do that, and it all depends on what you need it for. We cannot make those decisions for you, instead we can help you learn how to do it.Once you know the php/mysql basics and get stuck writing a script, please tell us what's wrong and we'll tell you why it doesn't work.

  9. Hey it's me again. I stripped an image rotator like this:

    <?php$folder = 'c:\WINDOWS\Web\Wallpaper./';$extList['jpg'] = 'image/jpeg';$handle = opendir($folder);while ($file = readdir($handle))  {	$file_info = pathinfo($file);	$fileList[] = $file;}$imageNumber = time() % count($fileList);header ('Content-type: '.$extList[ $imageInfo['extension'] ]);readfile($folder.$fileList[$imageNumber]);closedir($handle);?>

    It displays a random image. I don't want that. I suspect it's because of $imageNumber's definition.How can I get this script to display all images in the folder? The folder name will be replaced by a variable which is propagated through a link. I'll make sure the folder exists and contains images.Thanks all.

  10. databases are just tables, really, but with a nice eay way of selecting entries.For example, if I had a table called "members" wich holds the Usernames and emailsof people and I wanted to see the list of usenames: my_sql_query( "SELECT Username FROM Members" );For more (alot) of info, read the tutorial. Keep on with it, databases are very useful.
    I especially like functions as "SELECT * FROM members WHERE name='$name'"The results obtained by that query can be used in a variable and re-used in new queries. I use it to let people store blogs and personalized stylesheets.
  11. I played around with it a little, and tried to have it displayed as I would normally do with html data. The script queries the database and echoes the (php) output. So far so good.However, the echoed script itself needs to make a query too for html info. But instead of the desired html data all I see is variables. Too bad.It still leaves me with a pretty neat content manager for html pages. Anyone who desires a template of the so-called 'eggshell sitebuilder' can send me a pm.

  12. Hi. Can PHP code be loaded and executed from a database, which in turn loads and echoes html info from the same database? I want to be able to add and alter modules from my script using a content manager (which I already created to successfully add, alter and load html pages with).

  13. Favicons:

    <LINK REL="SHORTCUT ICON" HREF=favicon.ico>

    Put this code in the head of your html. I bet my left kidney this works for Firefox as long as there's a favicon in the root. It works for IE if you bookmark the site.[/bET]The frigger should be 16*16 pixels.Use this in combination with the <title> tag and your tab (if you browse tabbed) will be very distinguishable.Using Irfanview you can resize any image and save it as an ico file. You can even set a transparent color but that doesn't work for most browsers. Irfanview is safe and small (less than one mb).Download will start hereThis ten minutes of research has been brought to you free of charge. :)

  14. Hi guysI've created a php site with content manager. The code for the content manager is in a restricted area of the script. The login creates a session after which the webmaster menu will show. Every script called by that menu will check if the session exists.I'd like to see if the script is hack-proof, so I'm calling on you guys. This is the website, just click the email link on top of the page and I will reply to certify that I am the webmaster. The site is live, so if you manage to get into the webmaster menu please mail me a screenshot and recommendations to improve security.I know you guys will enjoy some hacking. So have fun. :)For the record: all css, html and php is written by me in nothing but a text editor.

  15. a link to the page would help too so we can see what it looks like in each browser

    'nuf saidOn the css: check all lines if they end on ';'. In the first css, I see background color needs one, and in the second one both background color and background image. (both on body)I'll get it validated for you, and check back.EDIT: according to the css validator the stylesheet contains error.Seriously, get it validated. That's the quickest way to check what's wrong and you can still post any errors you can't work out on your own. Validated code will work with most browsers except IE6 isn't guaranteed.
  16. EDIT: zanfranceschi Ninja'd me by about 5 hours. Stupid me...{margin-left: auto;margin-right: auto}This works with Firefox.If divs are placed between body tags (which I assume they are):body {text-align: center;}This works for Internet Explorer. I always use both to center a div. You can re-specify text-alignment in the div itself.This still causes your div to be in the top-center of the screen, while you'd like to have it dead-center. You 'should' be able to create a div that fills the window (let's call it a container), background white, no border.Specifications:

    # container {text-align: center;height: 96%;width: 96%;background-color: #ffffff;}# content {width: 700px;height: 500px;margin-left: auto;margin-right: auto;margin-top: auto;margin-bottom: auto;text-align: left;}

    Don't take my word for it, but fiddle around to see if this does what you would like it to do.(note: making the container too big may result in double scrolling, making the container too small may result in the content being off-center)

  17. SOLVED

    <html><head><style type="text/css">#deflink a {	width:234px;	height:91px;	font-size: 200%;	color:white;	text-decoration:none;}#deflink a:link {background-image:url('http://w3schools.invisionzone.com/style_images/w3sbanner.gif');}#deflink a:visited {background-image:url('http://w3schools.invisionzone.com/style_images/w3sbanner.gif');}#deflink a:hover {	background-image:url('http://www.w3schools.com/images/w3default80.jpg');	color:red;}</style></head><body><div id=deflink><a href="#">I am Text</a></div></body></html>

    Thanks Scott

  18. IE6 is non-compliant with css2.Normally I write a css for Firefox and adapt it for IE6.Another example of M$-CRAP's nazi-ism: "One browser for All".Can't help you much unless you post your css, but even then I wouldn't know what to fix how. I guess it's just a matter of trial and error; if something works for firefox (better yet: Opera) changes are one out of two it works for IE as well (take a margin of 1 into consideration). :)It's also possible to validate your css. The validator will be able to tell you what to change; it will work better with Firefox but 'less' with IE.

  19. Is there a way to roll over to another div once I mouse over it, or to change the background image and text color? I'm tired of creating animated buttons so I'm looking to create a manageable template.The code should work cross-browser, so on non-compliant ones as IE6 too.Thanks in advance.

×
×
  • Create New...