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.
Code is:
<?php
$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′>
<tr>
<th></th>
<th>Artist</th>
<th>Song</th>
<th>Album</th>
<th>Genre</th>
<th>Length</th>
</tr>”;
while($row = mssql_fetch_array($result))
{
echo “<tr>”;
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>”;
echo “</tr>”;
}
echo “</table>”;
mssql_close($dbhandle);
?>
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.