Link & Form<

liunx

Guest
I'm trying to create a page that functions as follows: The page has a list of "profile names" which I imagine will be hyperlinks. This page will also include an image of the person in the "profile", depending on which "profile name" was clicked.

So basically, depending on which name the user clicks, an image is loaded showing the person in question on the same page. The page will call itself as long as the user continues to click on the "profile names", loading each picture accordingly.

I have created images for each profile and gave them distinguishable but deterministic names, based on the names of the users. Where I'm getting confused is how to pass the information back to the calling page (the same page) if the user only clicks a link.

If I use only a hyperlink they will all obviously point to the same page and call the page w/o any information. I am thinking I need a <form></form> and contained within the form needs to be some information telling me the profile which to load. I can put this information in an <input type="hidden"> element, but when I click the link again none of the form information will be passed.

Is there a way to pass information directly from a hyperlink?page.php?id=someid


the someid could be the id of the profile they seek. then use $_GET['someid'] to get what they are looking for. very easy.Thanks for the reply but that looks a little foreign to me. I'm still much a beginner but here is what I understand so far about forms:

In my limited knowledge of PHP the only way I know to call "myself" with data is to do the following:

(from "thissamefile.php")


<form name="somename" method="get"
action="thissamefile.php">

<input type="hidden" value"someid">
</form>


My problem is, with a simple click I need to acknowdge what was clicked, determine the "someid" associated with that element, and call myself with that data in a form so I can pull it back out.

I've tred to put a hyperlink inside a <form> but as I suspected nothing was in the form when I read it on the other side.

page.php?id=someid

At first I though this was a logical expression, but it looks like an assignment. My best guess is "page.php?id" is an object that retains its value from page to page?

If I store my key value in someid, it then gets stored in "page.php?id", but then why do I still pull it out of "someid" on the other side.

In addition I've only used $_REQUEST so far, I'm guessing $_GET is used here because no form is sent?

I still don't understand where the element is the user much click on & what is the event that re-loads the same page. Thanks.I'm not sure how you're doing this now, but it seems to me like you could take the long easy route of javascript <script language="JavaScript">
<!--

img_paul = "paul.gif";
img_lisa = "lisa.gif";

function imgpaul(imgname)
{
imgname.src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/img_paul;">http://www.htmlforums.com/archive/index.php/img_paul;</a><!-- m -->
}

function imglisa(imgname)
{
imgname.src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/img_lisa;">http://www.htmlforums.com/archive/index.php/img_lisa;</a><!-- m -->
}
//-->
</script>

<A onmouseclick=imgpaul(photo)>Paul</a>
<A onmouseclick=imglisa(photo)>Paul</a>

<IMG border=0 height=10 name=photo src=http://www.htmlforums.com/archive/index.php/"default.gif" width=10> just do it like this while putting everything but the links and image in your head. if what your doing is gonna change all the time you could just change it with php because it's clientside. this way no forms are needed and you don't need to call any php other than what's contained in the script.

hope this is an option!

bendmanexpinch: I think you are misundestanding.

page.php is the page that has the script. id is what holds the value of what you need. yes you could use a form but using a link is no different than a form the uses the get method.

this is what it actully looks like

<!-- w --><a class="postlink" href="http://www.site.com/page.php?id=34">www.site.com/page.php?id=34</a><!-- w -->

34 is the number of the id you would need to load the profile. 34 comes from the db or where ever you have it coming from.

you can see this in action on almost every page here at the forums.

in your form you would want to check for the name that someid comes from.

<input type="hidden" value="someid" name="id">

than you get that id on the next page by looking at $_POST['id'] instead of GET. so either way it will work. a link maybe better and it is less code.
 
Back
Top