Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

php radio button link


  • Please log in to reply
No replies to this topic

#1 12Strings

12Strings

  • Members
  • 41 posts
  • OFFLINE
  •  
  • Local time:07:39 PM

Posted 18 March 2016 - 10:17 PM

Hi, my objective is to list database rows and by clicking one of the
radio buttons in the report, link to the url displayed on that line.
My code follows. I will surely appreciate your input. Thanks
 

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

  <?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 = FFD4FF ----------*/
    if($count=="1")
    { echo "<tr bgcolor='FFD4FF'>"; }

/* -------------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\"onclick=\"window.open('$res

['target']');\">

 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();
?>
  </table> </form></body></html>
 */

echo "</tr>" . PHP_EOL;
}
?>
</table></form></body></html>



BC AdBot (Login to Remove)

 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users