从($ _GET [“Value”])获取价值

时间:2018-02-04 13:55:20

标签: php sql syntax get row

//第一页      这是索引页面,这里我从列表中打印出行      电影有一些基本信息,标题,年份。      我还添加编辑和删除电影的链接,      这些工作通过传递该电影的行ID。

 $sql = "SELECT c.* , d.* FROM category c , movies d WHERE c.ID=d.ID";

 $result = $conn->query($sql);

 if ($result->num_rows > 0) {
    echo "<div class='floatbox collection'><table><tr><th>Titel</th><th>regissör</th><th>År</th><th>Genre</th><th>Ändra</th><th>Ta bort</th>";

 while($row = $result->fetch_assoc()) {
    echo 
    "<tr><td>".$row["title"]."</td><td>".$row["director"]."</td><td>"

    .$row["year"]."</td><td>".$row["category"]."</td>

    <td><a href='edit.php?row=".$row["ID"]."'>justera</a></td>
        // delete link to send ID to next page
    <td><a href='delete.php?delete=".$row["ID"]."'>stryk</a></td>";
 }
 echo "</table></div>";
} else { 
    echo "0 results";
}



// PAGE TWO
Here I have my $row[ID] trough $_get by the link on the previous page,
I have checked the value by "dumping" so I know that the row ID is in that
variable: The thing is, How do I call that $ID in my sql statement?
I'm trying to delete by calling that ID on the table row.

// Variable with correct ID value
if(isset($_GET["ID"]))  

if($_GET["ID"]) = $ID; // This doesn't work, Do I need to convert 
the $get_ID to a variable with the ID that can be called in the statement? 
or is my syntax wrong?

// Delete join
$sql = "SELECT * FROM movies, category  
       INNER JOIN category ON movies.ID = category.ID
       DELETE WHERE movies.ID = '$ID'"; // No syntax works here
       // Any help appreciated.

// konfirmering
if ($conn->query($sql) === TRUE) {
    echo "Register struket <br>
     <a href='panel.php'>Gå tillbaka</a>";
} else {
    echo "Fel vid anslutning : " . $conn->error;
}

1 个答案:

答案 0 :(得分:0)

根据您的代码,您的 delete.php 将是这样的:

public class Main(){
    public void main(String[]args){
        List<Round> arrRound = getRoundFromCSV();
        int maxPrize = arrRound.stream()
                               .forEach(round -> {
                                 round.getHits()
                                      .forEach(hit -> hit.getPrizeAmount());
                                });
    }
}