简体   繁体   中英

how to send data with php?

I'm trying to send player id to delete and update page and it doesn't send it.

i'm adding my table body here.

              <tr>
                <td><img src="<?php echo $readRow['Photo']; ?>" width='64px'></td>
                <td> <?php echo$readRow['ID']; ?></td>
                <td> <?php echo$readRow['Fname']; ?></td>
                <td> <?php echo $readRow['Lname']; ?></td>
                <td> <?php echo$readRow['Age']; ?></td>
                <td> <?php echo$readRow['Email']; ?></td>
                <td> <?php echo$readRow['Phone']; ?></td>
                <td><a href='update.php?id=$readRow[ID]' data-toggle="modal" data- 
                        target="#editplayer" class = 'btn btn-success'>Edit</a>
                <a href="delete.php" name = "Delete"  class = 'btn btn-danger'>Delete</a></td>
              </tr>
              <?php
              }
              ?>

please help.

You need <?php echo?> around $readRow[ID] . And you need to put that into the delete.php URL as well.

              <tr>
                <td><img src="<?php echo $readRow['Photo']; ?>" width='64px'></td>
                <td> <?php echo$readRow['ID']; ?></td>
                <td> <?php echo$readRow['Fname']; ?></td>
                <td> <?php echo $readRow['Lname']; ?></td>
                <td> <?php echo$readRow['Age']; ?></td>
                <td> <?php echo$readRow['Email']; ?></td>
                <td> <?php echo$readRow['Phone']; ?></td>
                <td><a href='update.php?id=<?php echo $readRow['ID']; ?>' data-toggle="modal" data- 
                        target="#editplayer" class = 'btn btn-success'>Edit</a>
                <a href="delete.php?id=<?php echo $readRow['ID']; ?>" name = "Delete"  class = 'btn btn-danger'>Delete</a></td>
              </tr>
              <?php
              }
              ?>

You can just add your id to be deleted as a GET parameter

 <a href="delete.php?id=<?php echo $readRow['ID']; ?>" name = "Delete"  class = 'btn btn-danger'>Delete</a></td>

However, I suggest you stay away from GET and use POST method, which is much more secure.

<form action="delete.php" method="post">
<tr>
<td><img src="<?php echo $readRow['Photo']; ?>" width='64px'> 
// ...other td elements
</tr>
</form>

You need to enclose player id with <?php and?> (PHP start and end tag respectively) as given below:

<a href='update.php?id=<?php echo $readRow[ID]; ?>' data-toggle="modal" data-target="#editplayer" class = 'btn btn-success'>Edit</a>
<a href="delete.php?id=<?php echo $readRow[ID]; ?>" name = "Delete"  class = 'btn btn-danger'>Delete</a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM