Tech Reviews, Guides, Articles, and Forums for PC Hardware, Modding, and Gaming Enthusiasts
Fury-Tech Forums

Go Back   Fury-Tech Forums > Software Forums > Programming and Coding

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-03-2004, 10:43 PM
freshtokyo's Avatar
Great Diviner
Great Diviner
 
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
freshtokyo is on a distinguished road
Send a message via AIM to freshtokyo
Default SIMPLE PHP TUTORIAL! (from me!)

checkity this boys and (girls?)
say you got a gallery page, or any page that you'd normally link out to a bunch of other pages containing the data. DO THIS INSTEAD!

Code:
<?php
	$image = "";
	if ( $_GET['class'] == "test") {
?>
	test image! [img]test.jpg[/img]
	
back
<?
	} elseif ( $_GET['class'] == "test2")  {
?>
	test image 2! [img]test2.jpg[/img]

<?
	} else {
?>
This is what the page displays to start with
links should be something like this link or image

<?
}
?>
Ok ok, that might be the most basic code, but after I did it, I couldn't help think of all the other things I can use it for using different variables from other pages, or use it whilst pulling info from a db!?! rock and roll (note to all: don't copy and past this code from this browser window, as tek and I have found out... it fucts it up)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-04-2004, 10:40 AM
freshtokyo's Avatar
Great Diviner
Great Diviner
 
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
freshtokyo is on a distinguished road
Send a message via AIM to freshtokyo
Default

questions comments suggestions welcome
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-04-2004, 11:19 AM
JD's Avatar
JD JD is offline
Great Diviner
Great Diviner
 
Join Date: Jun 2003
Location: Chicago
Posts: 1,162
Rep Power: 7
JD is on a distinguished road
Default

I don't know what that means. What a meaningful comment.
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-04-2004, 11:47 AM
freshtokyo's Avatar
Great Diviner
Great Diviner
 
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
freshtokyo is on a distinguished road
Send a message via AIM to freshtokyo
Default

I'm just looking for input on that code (aka, could it be done simpler, etc)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-04-2004, 11:57 AM
Tekime's Avatar
Administrator
Great Diviner
 
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
Tekime is on a distinguished road
Send a message via AIM to Tekime Send a message via MSN to Tekime Send a message via Yahoo to Tekime
Default

fresh my man I'm glad to see you're getting into this PHP thing so much.

Check it out though, I'm going to show you a different way to handle this kinda of thing.

Basically, this script is just taking an image name identifier and showing the correct image for it, no? Why not take this dynamic thing all the way and save ourselves a few more lines?

Code:
<?php

if($_GET['img'])
{    
    $image_dir = "/var/www/public_html/images/"; // Absolute URL   
    $image_rel = "images/"; // Relative URL

    $file = addslashes($_GET['img']); // Clean up filename

    if(file_exists($image_dir.$file))
    {
        echo "<img src=\"".$image_rel.$file."\" />";
    }
    else
    {
        echo "Error reading imagefile";
    }

}

echo "<a href=\"index.php\">Go Back</a>";

?>
Just off the top of my head, but now you can specify ANY imagename and it will automatically check for it before displaying it. No more control structures for each and every name!

That is if this is what you were trying to accomplish of course.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-04-2004, 12:08 PM
freshtokyo's Avatar
Great Diviner
Great Diviner
 
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
freshtokyo is on a distinguished road
Send a message via AIM to freshtokyo
Default

that is pretty dope, and I would use that in an image gallery, (althought the actually application I'm using the code I posted can't be as dynamic unless I pull it from a db, but that's cool)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-04-2004, 12:09 PM
freshtokyo's Avatar
Great Diviner
Great Diviner
 
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
freshtokyo is on a distinguished road
Send a message via AIM to freshtokyo
Default

hey, what does "addslashes" do?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-04-2004, 12:18 PM
Tekime's Avatar
Administrator
Great Diviner
 
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
Tekime is on a distinguished road
Send a message via AIM to Tekime Send a message via MSN to Tekime Send a message via Yahoo to Tekime
Default

addslashes() is used for escaping characteres so visitors don't have such an easy time of injecting malicious code into your scripts:

http://us3.php.net/addslashes

DEFINITELY worth understanding, it's very useful.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-08-2004, 09:44 AM
freshtokyo's Avatar
Great Diviner
Great Diviner
 
Join Date: Nov 2003
Location: In Maine
Posts: 1,638
Rep Power: 7
freshtokyo is on a distinguished road
Send a message via AIM to freshtokyo
Default

I figured it had something to do with that. thx mango
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Currently Viewing
Go Back   Fury-Tech Forums > Software Forums > Programming and Coding




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Photoshop Liquid Tutorial Tekime Fury-Tech Articles & News 1 06-21-2007 12:14 PM
Plain and simple...like my lyfe tnv Custom Modifications 2 08-12-2005 06:44 PM
Simple Maya Help. Cyd Graphics, Web Design, CSS & Scripting 6 04-12-2005 11:38 AM
Liquid Tutorial freshtokyo Graphics, Web Design, CSS & Scripting 10 04-02-2004 01:13 PM
New PS Tutorial in Graphics Forum freshtokyo Jibber Jabber 1 04-02-2004 11:26 AM


All times are GMT -5. The time now is 09:45 PM.


PHP Scripts
BidVerve Directory
PageRank Script
SEO Scripts
37 SEO Scripts
List Cleaner Script
Keyword Cleaner
Directory Script
Directory Script

Directories
BidVerve Directory
BidVerve Directory
Nerve Directories
Nerve Directories
Directory Grow
Directory Grow

Our Supporters
entertainment sites
online casino

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0 ©2007, Crawlability, Inc.