I am looking to auto-populate a php / html form with data as radio buttons to allow a user to choose from his own records and convert their selection into a reusable variable for another form.
I have got the login and password from database working fine and can create a session $variable
with the appropriate user_id
Then I get stuck with the right query and html construct. I have look at various examples to no avail.
My table is as follows
tableid Title Author published colour user_id ref_id
==================================================================
1 how to ski pete 2014 red 2 1
2 how to cook jones 2015 white 4 2
3 how to drive smith 2012 yellow 2 3
4 how to cook jones 2015 white 4 2
5 how to drive smith 2012 yellow 4 3
I have created the basic query to pull the data but am struggling to get this displayed as radio buttons for a single selection.
$queryOrders2="SELECT * FROM books WHERE user_id=$user_id";
$resultOrders2=mysql_query($queryOrders2);
$row = mysql_fetch_assoc($resultOrders2);
print_r(mysql_fetch_assoc($resultOrders2));
$Title = $row["Title"];
$Author = $row["Author"];
$published = $row["published"];
$colour = $row["colour"];`
Then I try to convert to radio buttons to allow for single record selection
<form action="display-selections.php" method="POST">
<input class="radio_style" id="Title" name="Title" type="radio" value="Title">
<input class="radio_style" id="Author" name="Author" type="radio" value="Author">
<input class="radio_style" id="published" name="published" type="radio" value="published">
<input class="radio_style" id="user_id" name="user_id" type="radio" value="user_id">
<input name="submitted" type="submit" value="Submit">
</form>
But the code is invalid and as I am quite new to PHP and still learning. I am stumped and there are just too many examples that seem to fall short one way or another.
I have tried so many different syntax and I am struggling to get my head around how to allow user selection of data from mysql in selectable format.
Any help or nudge in the right direction would be great.