Results 1 to 2 of 2

Thread: radio button link

  1. #1
    Join Date
    May 2014
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default radio button link

    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!

    HTML Code:
    <!DOCTYPE html><html>
    <head>
    <title>Email Visits</title>
    </head>
    <body><center>
     <form id="testform" name="testform" action="" method="post" 
    accept-charset="UTF-8">
    PHP Code:
     <?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();
    ?>
    HTML Code:
    </table> </form></body></html>

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    It should be outputting the same as echo "<td>";echo $res['target'];echo "</td>"; , except inside the value attribute of that radio input.

    If you check the source, is it the same?
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Help with Radio Button
    By JRR in forum HTML
    Replies: 1
    Last Post: 02-03-2014, 12:37 AM
  2. Replies: 2
    Last Post: 03-05-2013, 10:52 PM
  3. Code for radio button
    By rhodarose in forum PHP
    Replies: 1
    Last Post: 12-09-2010, 12:47 PM
  4. Radio Button CSS
    By farmdve in forum CSS
    Replies: 10
    Last Post: 03-16-2008, 02:42 AM
  5. PHP radio button hadling
    By calumogg in forum PHP
    Replies: 4
    Last Post: 10-15-2007, 06:47 PM

Bookmarks

Posting Permissions

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