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!
<?php
//-------------------------
// mypage.php
//-------------------------
$w_name = $_POST['who']; //get which link they clicked
if($w_name != "") { //check to see if who var is empty
echo " You clicked the ".$w_name." link!";
} else {
echo "No name specified!"; //deny if who var empty
}
?>
<form action='http://mypage.php' method='post'>
<a href='#' name='who' onclick='javascript:submit()'>Todd</a>
<a href='#' name='who' onclick='javascript:submit()'>John</a>
<a href='#' name='who' onclick='javascript:submit()'>Bill</a>
</form>
I haven't tried doing this yet in any of my projects, so if someone could show me the proper syntax to accomplish the above therory, I would be much appreciative.. thanks
well how does phpbb do it.. I mean if you goto memberslist and click a name it brings you to that users profile.. which is basically what I am trying to accomplish with links.. so that say some one clicks the link jason.. the user will be taken to mypage.php where Jason's info from the DB will be populated.. or if they click Bill, they will goto mypage.php where Bill's info from the DB will be poulated.. can a field be a link?? I just need to send the php script the users name and it will know where to look.. could someone show me an example.. thanks
Last edited by fresh on Mon Nov 01, 2004 7:08 am, edited 1 time in total.
PHP Manual: first call when having questions about PHP.
Google: second call when having questions about PHP.
Search Function of this forum: : third call when having questions about PHP.
Posting a new message: fourth call when having questions about PHP
Click on the first link below for further details.
hey no I was just using phpbb as an example.. and yes, I will be enumerating a list of names from my sql db.. I suppose I will try the javascript.. unless there is a php way of doing this.. I just think the less one sees the better off I will be.. thanks
<?php
//use a while loop to create a list of names
//put this link inside the while loop and $your variable can be pulled from
//the row
echo '<a href="mypage.php?userselect='.$yourvariable.'" />Link to page</a>';
//on the page where you need it to show the right profile
if (isset($_GET['userselect']))
{
$selectuser = "SELECT * FROM usertable WHERE user='$_GET[userselect]'";
@mysql_query($selectuser, $connect);
}
else
{
//the pages usual code
}
?>
At least this is what i usually do, unless i'm not following what your getting at.
fresh wrote:hey no I was just using phpbb as an example.. and yes, I will be enumerating a list of names from my sql db.. I suppose I will try the javascript.. unless there is a php way of doing this.. I just think the less one sees the better off I will be.. thanks
If you follow the link I posted and read the link, you'll understand that this is one of the most frequently asked questions. The PHP manual has dedicated an entire page just to that. So, I'd advise you to read: http://uk.php.net/FAQ.html