Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    use the button name in an SQL query

    hi,
    if somone can help me,

    i have a problem with my PHP and SQL code,

    in fact i have a "while" function that create many button pictures in an HTML page,

    each picture has the format:

    <img src="./images/bat.png" border="0" alt="<?php echo $row[$i]["CSTip"]; ?>" name[/COLOR]="<?php echo $row[$i]["CSTip"]; ?>" width="80" height="90"></img>

    the idea is when i click on a picture, i should generate an SQL query:

    $query = "SELECT volt FROM table where picture_name='%NAME%'";

    the NAME value shoold be the name in the picture definition to differentiate between them. i dont know the correct syntax

    So how can i reslove this problem??

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Are you submitting a form when an image is clicked? Or are you initiating a POST request via AJAX?

    Either way, DOM element information (other than values in form elements) don't get sent to the server, unless you specifically send it. You'll need to use a bit of Javascript to grab the value of your "name" attribute and send it down the pipe when you kick back to the server (however it is you do that).

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, i submit a form, so when i click on the image, i will redirect to a tread that filter all my informations in the database according to the name of the image where i click,

    for example; in the while function, the query fetch all the database and select distinct the ip addresses, then it creats images for each ip address founded and diferenciates these images by their name which is the ip address... so when i click on an image, i should in an sql query do a sum to all the numbers that have an ip address the name of the button....

  • #4
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    in an other way:

    the definition of the image button:

    <a onClick="window.open('real_time_graph-v1.php','Quality_Graph','width=1000,height=500,resizable=yes,scrollbars=yes')" target="_blank">
    <img src="./images/bat.png" border="0" alt="<?php echo $row[$i]["CSTip"];?>" name="<?php echo $row[$i]["CSTip"];?>" width="80" height="90"></img>


    the Sql query:
    $voltage_query = "SELECT volt FROM volt_table where date='%CSXdate%' and ipaddress= '%the name value in the image definition%'";

  • #5
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Send real_time_graph-v1.php the information via the query string. Use Javascript to pull the information out of the name attribute.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •