# radio button link



## ckir5951 (Nov 16, 2014)

Hi, my code successfully creates a dropdown menu from a database and upon selecting a "target", displays the record in the form of a table including a radio button. My objective is to click the button to link to the "target". The "target" fields are
email addresses or URLs. Any pointers? Thanks in advance.

The code follows:

<!DOCTYPE>test menu create


<?php
$con=mysqli_connect("localhost","root","password","DB");
//============== check connection
if(mysqli_errno($con))
{ echo "Can't Connect to mySQL:".mysqli_connect_error(); }
else
{ echo "Connected to DB
"; }
//This creates the drop down box
echo "";
echo ''.'--- Select account ---'.'';
$query = mysqli_query($con,"SELECT target FROM testbl");
$query_display = mysqli_query($con,"SELECT * FROM testbl");
while($row=mysqli_fetch_array($query))
{echo "".$row['target']
.'';}
echo '';
?>

<!DOCTYPE>test menu display


<?php
$con=mysqli_connect("localhost","root","password","DB");
if(mysqli_errno($con))
{echo "Can't Connect to mySQL:".mysqli_connect_error();}
if(isset($_POST['target']))
{
$name = $_POST['target'];
$fetch="SELECT target, thingamajig FROM testbl WHERE target = '".$name."'";
$result = mysqli_query($con,$fetch);
if(!$result)
{ echo "Error:".(mysqli_error($con)); }

//display the table
echo '
'. 'test menu'. ''.'
'.'target'.''.'thingamajig'.'$data[0]$data[1]
'.'
'.'
'.'
'.'
';
while($data=mysqli_fetch_row($result))
{ echo ("
"); }
echo ''.'
'.'
'.'
'.'
';
echo '
'.'
'.'
'.'';
}
?>​


----------



## JiminSA (Dec 15, 2011)

This possible solution is untested (top of my head stuff):
Alter this code to include a link ...

```
{ echo ("[TR][TD]$data[0][/TD][TD]$data[1][/TD][/TR]"); }
```
so ...

```
{ echo ("[TR][TD]$data[0][/TD][TD]$data[1][/TD][TD][URL=$data[0]]Link[/URL][/TR]"); }
```
This assumes that the first subscript of $data holds a valid url
OR

```
{ echo ("[TR][TD]$data[0][/TD][TD]$data[1][/TD][EMAIL=$data[0]]Link[/EMAIL][/TR]"); }
```
This assumes that the first subscript of $data holds a valid email address.

You will have to build a mechanism to distinguish between urls and email addresses and alter the code accordingly.


----------



## JiminSA (Dec 15, 2011)

If you want the link to be a radio button just change *Link* to


----------



## ckir5951 (Nov 16, 2014)

Thanks so much-great!. This is the first coding forum I used about 10 years ago. A mod, Old Dirt led me thru my 1st xampp install. Again, Thanks!.


----------



## JiminSA (Dec 15, 2011)

Pleasure @ckir5951 - do you want to mark this thread solved, please?


----------



## ckir5951 (Nov 16, 2014)

yes thanks, is there a link to that?


----------



## JiminSA (Dec 15, 2011)

There should be a button option at the head of the thread, available to the thread starter only ...


----------



## JiminSA (Dec 15, 2011)

Ansul said:


> can you tell me what is this mean


Not quite sure what you are referring to @Ansul ?


----------



## JiminSA (Dec 15, 2011)

ckir5951 said:


> yes thanks, is there a link to that?


There is a link which allows you to mark the thread as solved, but it is only available to the person who started the thread. It can be found (only by them) at the very start of the thread. I hope this is a better explanation.


----------

