Php and images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
musbah
Forum Newbie
Posts: 11
Joined: Mon Apr 25, 2011 8:52 pm

Php and images

Post by musbah »

Hello, I'm not here to beg for code or anything i just need some help as to something I'm doing.

I'm fairly good with php and I have been trying to do something with no luck.

I want to make 3 links and 3 hidden images. When you click on 1 link an image appears, when you click on the other one another image appears and takes the place of the first one.

I can easily do that with either css and javascript but I was searching for a way to be able to send the information to php.

For example if the person is seeing image1 then clicks submit i want php to be able to get the url or some way to say that the person chose image1 , same if he chose image 2 and image 3.

I know that php is server side and not client side but I'm trying to find a way to use ajax and all but I'm not really good at it.

I would really appreciate some place to start, like i said at the beginning not here to get someone to do my job I just need a place to start because up to this point I have got nothing.

Thank you, appreciate any help.
ScOrPi
Forum Commoner
Posts: 44
Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ

Re: Php and images

Post by ScOrPi »

Hi , try this ajax ..


[text]var xmlhttp;
function GetXmlHttpRequest() {
xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
xmlhttp = new XMLHttpRequest();

}
}
}

function load_img(iType) {
GetXmlHttpRequest();
xmlhttpt.open("GET","page.php?type="+iType,true) ;
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
document.getElementById('someid').innerHtml = xmlhttp.responseText;
}
}
}
[/text]

and for your php page you can make switch or if ... etc .

but for easy way make it with js or jquery :)
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Php and images

Post by social_experiment »

To retrieve any data from the url in php use $_GET;

Code: Select all

 <form action="page.php?id=5" method="post" />
To access the value of id you would use $_GET['id'] and it will contain a value of 5
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply