0

i want to send Variable to a php function when a link clicked
how to do that???


so far i got to here but it doesn't work. :( plz help mee

echo " <A href=\"Carscript.php\"
onMouseOver=\"SwapOut('$name')\"
onMouseOut=\"SwapBack('$name')\"
onclick=\"func($name);\" > ";

3
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by UzuNarU
0

ignore the Carscript.php .function is in the same file

Edited by y2kshane: n/a

0
<?php
    session_start();
    $_SESSION['type']="muscles";

echo '

<html>
<head>
    <link rel="stylesheet" type="text/css" href="maker.css" />
    <script type="text/javascript" src="maker.js"></script>
<head>

<body>

<div class="maker">

    <center><img border="0" src="seperator.png"/></center>

    <center><img border="0" src="Maker Name/Namemain.png" name="makerNameImage"/></center>

    <center><img border="0" src="seperator.png"/></center>

    <center>
    <div class="bttnmaker">
    ';


    function func($fName)
    {

        $_SESSION['maker']=$fname;
        echo $_SESSION['maker'];

    }





    mysql_connect('localhost','root','');
    mysql_select_db('car_info_db');

    $result_mani=mysql_query("select * from mani_table");
    $count=0;
    $name_mani;

    while($entity=mysql_fetch_array($result_mani))
    {
        $type_bool=$entity['Muscles'];

        if($type_bool==1)
        {
            $count++;
            $name_mani[$count]=$entity['mani_name'];

            $name=$name_mani[$count];
            $fix_name="Maker Badge Black/".$name.".png";

            echo "
            <A href=\"Carscript.php\" 
                onMouseOver=\"SwapOut('$name')\" 
                onMouseOut=\"SwapBack('$name')\"
                    onclick=\"func('$name')\" >  ";

            echo "
            <img border=\"0\" name='$name' src='$fix_name'/>
            </A> ";

            if($count%6==0)
            { echo '</br>';}


        }
    }




 echo '


    </div>
    </center>
</div>

<body/>
<html/>  ';


?>

Edited by Reverend Jim: Fixed formatting

0

Hello,

Please update following code in your code:

$fix_name="Maker Badge Black/".$name.".png";

?>

<a href='Carscript.php' onMouseOver="SwapOut(<?php echo $name; ?>)" onMouseOut="SwapBack(<?php echo $name ?>)" onclick="<?php echo func($name); ?>" >
<img border="0" name='<?php echo $name ?>' src='<?php echo $fix_name ?>'/>
</a>


<?
if($count%6==0)

I hope it will help you!

0

Another option for if you wish the keep you links inside the "echo"

echo "<A href='Carscript.php'" .
    "onMouseOver='SwapOut(" . $name . ")'" .
    "onMouseOut='SwapBack(" . $name . ")'" .
    "onclick='func(" . $name . ")'> " .
    "<img border='0' name='" . $name . "' src='" . $fix_name . "'/>" .
    "</A>";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.