basic question but hard to find on google.
Moderator: General Moderators
basic question but hard to find on google.
Hi!
How can i use normal links as "buttons"?
So that something happens when u click the link "not a button".
//Thanks in advance
//Thomas
How can i use normal links as "buttons"?
So that something happens when u click the link "not a button".
//Thanks in advance
//Thomas
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: basic question but hard to find on google.
Depends on what you want to happen? You can set the onclick event for the link to call some javascript function, or you can call a php page and pass it some values.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: basic question but hard to find on google.
well i thought of basicly do a calculation or so.
Exampel code
Those kind of actions where what i thought of. =)
Exampel code
Code: Select all
If ("link where pressed"){
$sql="SELECT * FROM konto WHERE saved_id=$id";
$result = mysql_query($sql) or die(mysql_error());//Välj all info i tall. //hämtar all info från tabell
while($row = mysql_fetch_array( $result )) //hämtar info från tabell.
{
$user = $row['user'];
$pengar = $row['pengar'];
}
}
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: basic question but hard to find on google.
A simple example based on what "I think" you're asking:
page.php
Code: Select all
<a href="page.php?action=something">Click link</a>Code: Select all
if(isset($_GET['action'])) {
switch($_GET['action']) {
case 'something':
//do something
default:
//do a default action
}
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: basic question but hard to find on google.
yea thats basicly but i where more think in the line of all done on 1 page. so that if the link is pressed do a action. =)
//Thanks in advance
//Thomas
//Thanks in advance
//Thomas
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: basic question but hard to find on google.
Just put it in one page then:Goofan wrote:yea thats basicly but i where more think in the line of all done on 1 page. so that if the link is pressed do a action. =)
page.php
Code: Select all
<?php
if(isset($_GET['action'])) {
switch($_GET['action']) {
case 'something':
//do something
break;
case 'this':
//do this
break;
case 'that':
//do that
break;
default:
//do a default action
}
}
?>
<a href="page.php?action=something">Click link</a><br />
<a href="page.php?action=this">Click link</a><br />
<a href="page.php?action=that">Click link</a><br />
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: basic question but hard to find on google.
thanks a bunch! 
Re: basic question but hard to find on google.
Is there a way, using your example and only php, to do that without reloading the page, or do I have to use JavaScript for that?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: basic question but hard to find on google.
JavaScript.JackD wrote:Is there a way, using your example and only php, to do that without reloading the page, or do I have to use JavaScript for that?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.