echoing radio buttons
This is my first post on this site. I've spent the past 2 months learning from scratch how to make my own website but I've finally run into a problem where I'm a little oblivious.
What I'm trying to do is select a table from my database and echo it into an html table. In this case, the table is a list of songs and their artists. So each row will be another song and artist. But in every new row I want to put in a radio button so the user gets to choose which song they would like.
$myServer = "myserver";
$myUser = "myusername";
$myPass = "mypassword";
$myDB = "mydatabase";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT * ";
$query .= "FROM tblPlaylist ";
//execute the SQL query and return records
$result = mssql_query($query);
echo "<table border='1'>
while($row = mssql_fetch_array($result))
echo "<td>" . ********** . "</td>";
echo "<td>" . $row['Artist'] . "</td>";
echo "<td>" . $row['Song'] . "</td>";
echo "<td>" . $row['Album'] . "</td>";
echo "<td>" . $row['Genre'] . "</td>";
echo "<td>" . $row['Length'] . "</td>";
Where you see ********** is where I want to put a radio button for each row but I just don't know how. Thanks for your help.
Assuming for this example the primary key field is "id", something like:
PS: If you use this forum's [php]...[/php] bbcode tags around your code snippets, they'll be much easier to read.
echo "<td><input type='radio' name='id' value='" . $row['id'] . "' /></td>";
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)