Welcome! Log In Create A New Profile

Advanced

POST Radio Button & Checkbox selection

Posted by 42893275-P 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
POST Radio Button & Checkbox selection
May 19, 2013 11:34AM
Hi. Please help! I'm stuck... My selection is not working as expected "both the radio button and checkbox selections" are posting empty values into the selections table... "PLEASE HELP" what am i doing wrong?
"TEST CODE"

$fixture_id $_POST['fixture'];

if ($_POST['submit']){
$query = "INSERT INTO selections (opponents, date, venue) VALUES ('".$fixture_id."')";
$result = mysql_query($query);

}
avatar
Mac
Re: POST Radio Button & Checkbox selection
May 20, 2013 08:40AM
I will not respond because you do not follow instructions about posting code.
Re: POST Radio Button & Checkbox selection
May 20, 2013 10:35AM
Hi. I forgot to mention, the reason why i couldn't format my test code as instructed is I posted the question using my phone "mobile browser" the options to format code aren't available on mobile, sorry but that was the only way i could post "had no access to a PC with Internet connection". Please help.

Language: PHP
$fixture_id = $_POST['fixture']; if ($_POST['submit']) { $fixture_query = "INSERT INTO selected (opponents, date, venue) VALUES ('".$fixture_id."')"; $result_fixture = mysql_query($fixture_query); } $player_id = $_POST['player']; if ($_POST['submit']) { for ($i = 0; $i < count($player_id); $i++) { $query = "INSERT INTO selected (name, surname, position) VALUES ('".$player_id."')"; $result = mysql_query($query); } }
avatar
Mac
Re: POST Radio Button & Checkbox selection
May 20, 2013 12:41PM
Your insert query has 3 fields listed (...selected (opponents, date, venue)...) but you only insert one value.... and it does not even related to the fixture/player id.

Review insert statements.
Re: POST Radio Button & Checkbox selection
May 20, 2013 12:51PM
From the selection page fixture_id and player_id is what i used to retrieve data from the two tables and display to manager... I can select and preview the selections "Show Selected Fixture and Players"... so i figured i should use the id's to populate the selections table. Where am i losing direction...?
avatar Re: POST Radio Button & Checkbox selection
May 20, 2013 03:04PM
The players_id is not important when it comes to the database. (It might be important for getting player names though - depending on your code) What is important is the players names, because that is what the public will see on the fixtures public page. You need to have positions and fixture id's in your selections table

Selection_id, Fixture_id, Batsman1, Batsman2, Batsman3 etc.
1 1 John White, John Blue, John Brown

You need to figure out a way to get those player names assigned to those positions in the table.

As things are, you are trying to enter one value into three columns, through loops,without making any associations at all.
Re: POST Radio Button & Checkbox selection
May 20, 2013 05:05PM
Owk... it's now starting to make sense. so by saying the player_id is not that important for selections table you mean the selections table needs e.g.
selection_id
fixture_id
wing
right_back
central_mid

and no fields for the opponents, date, venue I'm asking this cause my idea was to capture the selected "Fixture: Opponent, Date, Venue" and "Player: Name, Surname, Position" and insert that into selections table and create one record per selection.

Thanks will definitely try out your suggestion.
Sorry, only registered users may post in this forum.

Click here to login