Hi all, maybe i posted in wrong forums so ill try here
I have 3 tables
games, membergames, members.
games.games_id is matched to membergames.Games_id and members.user_id is matched to membergames.Member_id.
I want to be able to delete rows from membergames to break the relationship between games and members. I do not have a primary key on the membergames table. So my question is..should I have a primary key there?
The reason im asking is because im having trouble writing my php script to delete the row. So here is an example of how i have another delete working. I need my row to delete similar if possable.
the id is passed through the url like so:
<a href=\"member_commit.php?action=delete&type=user&id={$record->user_id}\">[delete]</a>
The php commit page reads it and deletes the user. But since I dont have a primary key for the membergames page im not sure how to write the code so that it will delete the row. Any help is appreciated.
case "delete":
switch ($_GET['type']) {
case "user":
if (!isset($_GET['do']) || $_GET['do'] != 1) {
?>
<p align="center" style="color:#FF0000">
Are you sure you want to delete this <?php
echo $_GET['type']; ?>?<br>
<a href="<?php echo $_SERVER['REQUEST_URI']; ?>&do=1">yes</a>
or <a href="member_view.php">Index</a>
</p>
<?php
} else {
if ($_GET['type'] == "user") {
// delete reference to member
$sql = "DELETE xsm_member, xsm_membergames
FROM xsm_member
LEFT JOIN xsm_membergames ON xsm_membergames.Member_id = xsm_member.user_id
WHERE " . $_GET['type'] . "_id = '" . $_GET['id'] . "'";
}
}