Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: radio button link  (Read 6531 times)

0 Members and 1 Guest are viewing this topic.

12Strings

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    radio button link
    « on: September 21, 2015, 11:47:17 AM »
    Hi, another fun project:
    I'm printing a list from a table alternating line colors. I'm including
    a radio button on each line to link to the URL "target". I've greatly
    edited offerings from the net and all is well except that the buttons
    do nothing. I don't understand the line:
    echo "<input type=\"radio\" name=\"select\" value=\"{$res['target']}\">";
    Thanks for any help!



    Code: [Select]
    <!DOCTYPE html><html>
    <head>
    <title>Email Visits</title>
    </head>
    <body><center>
     <form id="testform" name="testform" action="" method="post"
    accept-charset="UTF-8">

     
    Code: [Select]
    <?php
    $host
    ="localhost"$username="root"$password="cookie"
    $db_name="homedb"$tbl_name="emailtbl";

    /* Connect to server and select databse */
    mysql_connect("$host""$username""$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // Define $count
    $count "";

    $sql="SELECT * FROM emailtbl ORDER BY target ASC";
    $result=mysql_query($sql);

    echo 
    '<table border="1" cellspacing="0">';
    while(
    $res=mysql_fetch_assoc($result))
     {
    // Add 1 to the row count
        
    $count=$count "1";

    /* -------------If $count==1 table row color = #FFC600 ----------*/
        
    if($count=="1")
        { echo 
    "<tr bgcolor='#FFC600'>"; }

    /* -------------If $count==2 table row color = #ccffff ----------*/
        
    if($count=="2")
        { echo 
    "<tr bgcolor='#ccffff'>"$count=$count "2"; }

    echo 
    "<td>";
    echo 
    "<input type=\"radio\" name=\"select\" value=\"{$res['target']}\">";
    echo 
    "</td>";
    echo 
    "<td>";echo $res['target'];echo "</td>";
    echo 
    "<td>";echo $res['username'];echo "</td>";
    echo 
    "<td>";echo $res['password'];echo "</td>";
    echo 
    "<td>";echo $res['emailused'];echo "</td>";
    echo 
    "<td>";echo $res['lastused'];echo "</td>";
    echo 
    "<td>";echo $res['purpose'];echo "</td>";
    echo 
    "<td>";echo $res['visits'];echo "</td>";
    echo 
    "<td>";echo $res['saved'];echo "</td>";
    echo 
    "</tr>";

     }
    echo 
    '</table>';
    mysql_close();
    ?>


     
    Code: [Select]
    </table> </form></body></html>

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: radio button link
    « Reply #1 on: September 21, 2015, 11:54:49 AM »
    What is your local host?
    Do you see the code connecting to the local host?

    12Strings

      Topic Starter


      Rookie

      • Experience: Experienced
      • OS: Windows 7
      Re: radio button link
      « Reply #2 on: September 27, 2015, 08:43:49 PM »
      explain your post please

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: radio button link
      « Reply #3 on: September 28, 2015, 12:48:34 AM »
      Do you have a local host?
      For example, the local host might be:
      127.0.0.1
      But a jump  to that IP will generate an error unless there is a service at location.

      Why Is the Localhost IP 127.0.0.1?


      The above is a tutorial that explains in more detail.

      Meanwhile, you could try code that does not require a local host.