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);\" > ";

Recommended Answers

All 5 Replies

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

can you please share your script, that will give us more idea for understanding..

<?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/>  ';


?>

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!

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>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.