how can I delete athletes from my database

Hi I need to be able to add a delete colum to my display table shown below, so that I can successfully remove any number of athletes. I would then like to be able to provide some feedback that the athletes where successfully removed. Please help as I'm new to this and I'm struggling to understand it all
<?php

include 'assignment2Connect.inc.php';

$query = "SELECT image, lname, fname, gender, sport, name FROM tblolympicAthletes
                  JOIN tblCountry ON (tblolympicAthletes.countrynationcodeID = tblCountry.countrynationcodeID)
order by lname";
$result = mysql_query($query);

echo"<table>";
echo"<tr><th>Image</th><th>Last Name</th><th>First Name</th><th>Gender</th><th>sport</th><th>Country</th></tr>";
while ($row = mysql_fetch_assoc($result))
{
      echo("<tr>");
      foreach($row as $index=>$value)
      {
      if ($index == 'image')
            {
                  echo("<td><img src=$value /></td>");
            }
            else
            {
                  echo("<td>$value</td>");
            }
            }
                  echo("</tr>");
            
}
echo("</table>");
?>

Also here is my Athlete table

include 'assignment2Connect.inc.php';

$createTable = "DROP TABLE IF EXISTS tblolympicAthletes";
$result = mysql_query($createTable);

$createTable = "create table tblolympicAthletes
(
athleteID  int(6) not null auto_increment,
image   varchar(20) not null,
lname      varchar(20) not null,
fname      varchar(20) not null,
gender      varchar(1) not null,
sport      varchar(50) not null,
countrynationcodeID int(5) not null,

PRIMARY KEY(athleteID)
)";

$result = mysql_query($createTable);

function createRecordA ($image, $lname, $fname, $gender, $sport, $countrynationcodeID)
{
$insertQuery = "insert into tblolympicAthletes (image, lname, fname, gender, sport, countrynationcodeID) values ('$image', '$lname',
'$fname', '$gender', '$sport', '$countrynationcodeID')";
$result = mysql_query($insertQuery);
}
createRecordA('dan.jpg alt=dan', 'Olaru', 'Dan', 'M', 'Archery', '1');
createRecordA('Gemma.jpg alt=gemma', 'Flynn', 'Gemma', 'F', 'Hockey', '2');
createRecordA('Sona.jpg alt=sona', 'Bernardova', 'Sona', 'F', 'Synchronised-swimming', '3');
createRecordA('Robert.jpg alt=robert', 'Elder', 'Robert', 'M', 'Archery', '4');
createRecordA('Gian.jpg alt=gian', 'Sibello', 'Gianfranco', 'M', 'Sailing', '5');
createRecordA('Charlotte.jpg alt=charlotte', 'Harrison', 'Charlotte', 'F', 'Hockey', '2');
createRecordA('Anne-marie.jpg alt=anne-marie',  'Rindom', 'Anne-Marie', 'F', 'Sailing', '6');
createRecordA('Anna.jpg alt=anna', 'Kulkina', 'Anna', 'F', 'Synchronised-swimming', '7');
createRecordA('C.jpg alt=c', 'Eskilsson', 'Christofer', 'M', 'Diving', '8');
createRecordA('Ger.jpg alt=ger',  'Owens', 'Ger', 'M', 'Sailing', '9');
createRecordA('Katie.jpg alt=katie',  'Skelton', 'Katie', 'F', 'Synchronised-swimming', '10');
createRecordA('Emily.jpg alt=emily',  'Naylor', 'Emily', 'F', 'Hockey', '2');
createRecordA('Anna1.jpg alt=anna',  'Pysmenska', 'Anna', 'F', 'Diving', '11');
createRecordA('Xi.jpg alt=xi',  'Dai', 'Xiaoxiang', 'M', 'Archery', '12');
createRecordA('Olena.jpg alt=olena',  'Fedorova', 'Olena', 'F', 'Diving', '11');

Cheers
stumpbossAsked:
Who is Participating?
 
Cornelia YoderArtistCommented:
stumpboss, I hate to throw cold water on your question, but the rules of EE prohibit experts from helping you do a scholastic assignment in this blanket way.

We are allowed to answer specific questions if you can rephrase to ask about some point where you are having trouble, but not to guide you step by step through your assignment.
0
 
stumpbossAuthor Commented:
ok sorry didn't  think I was doing that, just wanted some help with one piece of the puzzle
0
 
Cornelia YoderArtistCommented:
Which specific piece and what is your question about it?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
stumpbossAuthor Commented:
how do I add a delete radio button to my table
0
 
Cornelia YoderArtistCommented:
You have a database "table" and an html "table".  I'm assuming you want to add a delete button to the html table where you are displaying the info to some user.  Right?  And then when that button is pushed, you want to remove that athlete from the database table?

You will need to create a "form" and a submit button.  The submit button will say "Delete" on it, and the form will contain a hidden input with the athlete id for that athlete, so when the button is clicked, the form is triggered and the id of that athlete passed to your form processing action script.

Start by reading about <form and how it works.  Then create a <form within the html table row for each athlete.  Within the form, put a hidden input and a submit button.

In the action script that the form triggers, retrieve that input, use the id to delete from your database, and then echo out a confirmation message.

Things to read about:
html <form .....
html <input type=hidden ....
html <input type=submit ....
php array $_POST
MySQL DELETE
php echo
0
 
Cornelia YoderArtistCommented:
If you want to get a little more sophisticated, you can use checkboxes for each athlete and a single submit button to delete all the checked ones.  (Read about <input type=checkbox)

You could use a radio button to select exactly one of the athletes if you really want a radio button, instead of a form in each line of the table (Read about <input type=radio)
0
 
stumpbossAuthor Commented:
Thanks for the info I've looked around at all your suggestions and had ago at it, but still I'm unable to accomplish it

This is the result I get
0
 
stumpbossAuthor Commented:
what I really need is the  th along the top and all records displayed in the td like this

lname               fname            gender            sport             country              population          delete

mike                 may                   m                    ......               ........                      .......             checkbox

Then I would be able to select the athletes to delete as you suggested earlier can you give me any clues please
0
 
Cornelia YoderArtistCommented:
Clue:  Read about formating HTML tables, in particular how to use the <table>, <tr> and <td> tags to format it the way you want it to look.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.