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>
Related
I tried the following code to show my SQL database data in a table in my dashboard
<tbody>
<?php
while ($row = $result->fetch_assoc()):?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><img src="<?php echo $row['image']; ?>" width=100px height=100px></td>;
<td><?php echo $row['class']; ?></td>
<td><?php echo $row['reg_no']; ?></td>
<td><?php echo $row['capacity']; ?></td>
<td><?php echo $row['oname']; ?></td>
<td><?php echo $row['province']; ?></td>
<td><?php echo $row['district']; ?></td>
<td><?php echo $row['contact']; ?></td>
<td><a href="#" class="btn btn-warning btn-circle editbtn">
<i class="fas fa-edit"></i></a></td>
<td><a href="#" class="btn btn-info btn-circle viewbtn">
<i class="fas fa-eye"></i></a></td>
<td><a href="#" class="btn btn-danger btn-circle deletebtn">
<i class="fas fa-trash"></i></a></td>
</tr>
<?php endwhile; ?>
</tbody>
But that image column image does not show has an image
Result show like this:
my result
How to solve that problem
To me it seems your are inserting to the src attribute the context of the file rather then the URL of the image.
you are saving the image content it self in the DB,
check this out :
https://www.codexworld.com/upload-store-image-file-in-database-using-php-mysql/
<?php
while($row = mysqli_fetch_array($results)){
?>
<tbody>
<tr>
<td> <?php echo $row['Product_ID'] ?></td>
<td> <?php echo $row['Product_Name'] ?></td>
<td> <?php echo $row['Product_Price'] ?></td>
<td> <?php echo $row['Product_Stock'] ?></td>
<td> <button type="submit" name="add" id="<?php $row['Product_ID'] ?>" onclick="func(<?php $row['Product_ID'] ?>)"> Add </button></td>
</tr>
<?php } ?>`
<script type="text/javascript" method="post">
function func(id){
window.alert(id);
};
</script>
Is there a way I could store id of my button named add?
I've to store multiple product ids and use them in a receipt that would be generated using product ids. the method of the form is POST but I don't know how to get the id
Replace this
func(<?php $row['Product_ID'] ?>)
With This
func(<?php echo $row['Product_ID']; ?>)
<table class="table admin-table list-table nurserytwo-table">
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Code</td>
<td>Active</td>
<td>Edit</td>
</tr>
</thead>
<tbody>
<?php foreach($nurseries->result() as $nursery) { ?>
<tr>
<td><?php echo $nursery->id; ?></td>
<td><?php echo $nursery->name; ?></td>
<td><?php echo $nursery->code; ?></td>
<td><?php echo set_bool($nursery->active); ?></td>
<td><span class="glyphicon glyphicon-edit"></span> <?php echo
anchor('admin/nurseries/edit_nursery/'.$nursery->id, 'Edit', 'class="edit-
link"'); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
This is my current table code and I have had a good look around to see if I can work out how to do this but I am really new to php and can't seem to get my head around it. I need to add a delete button after the edit one and I know I could do this via a delete.php but no idea where to start. Any help would be much appreciated.
UPDATED:
This is what I have currently:
}elseif( $action == "delete_nursery_course" ){
if($id) {
$q = $this->db->where('id', $id)->delete('nursery_courses');
if($this->db->affected_rows() > 0) {
if($this->input->is_ajax_request()) {
$this->output->enable_profiler(FALSE);
echo "SUCCESS"; die();
}else{
set_flash_message('Nursery deleted successfully.',
'success');
}
}else{
if($this->input->is_ajax_request()) {
$this->output->enable_profiler(FALSE);
echo "Something went wrong. Please try again."; die();
}else{
set_flash_message('Something went wrong. Please try
again.', 'error');
}
}
And here is the html:
<table class="table admin-table list-table nurseryone-table">
<thead>
<tr>
<td>ID</td>
<td>Name</td>
<td>Colour</td>
<td>Active</td>
<td>Edit</td>
<td>Delete</td>
</tr>
</thead>
<tbody>
<?php foreach($nursery_courses->result() as $nursery_course) { ?>
<tr>
<td><?php echo $nursery_course->id; ?></td>
<td><?php echo $nursery_course->name; ?></td>
<td><div style="background:<?php echo $nursery_course->colour; ?>"
class="course-colour"></div></td>
<td><?php echo set_bool($nursery_course->active); ?></td>
<td><span class="glyphicon glyphicon-edit"></span> <?php echo
anchor('admin/nurseries/edit_nursery_course/'.$nursery_course->id, Edit', 'class="edit-link"'); ?></td>
<td>
<span class="glyphicon glyphicon-trash"></span> <?php echo
anchor('admin/nurseries/delete_nursery_course/'.$nursery_course->id,
'delete', 'class="delete-link"'); ?></td>
</tr>
<?php } ?>
</tbody>
</table>
You could use only html and javascript with jquery to use ajax requests to make an edit and delete button.
HTML:
<td class="text-right">
<a class="edit btn btn-sm btn-default" href="javascript:;">
<i class="icon-note"></i>
</a>
<a class="delete btn btn-sm btn-danger" href="javascript:;">
<i class="icons-office-52"></i>
</a>
</td>
And in your javascript file you have to define the onclick events for this a buttons.
Here's a Plunker example with html and javascript code:
Editable Table
Also you could use jquery DataTables to make it easier and better.
Hope its help you.
Trying to open a new window using a tag using target attribute but it is not working. Here is my code:
<tr>
<td>
<?php echo $count;?>
</td>
<td><a class="oiu" href=<?php echo "eventdetail.php?idno=".$row[ 'E_id'];?>><u><?php echo $row['E_name'];?></u></a>
</td>
<td><a class="oiu" href=<?php echo "http://maps.google.com/maps?saddr=".$cadd. "&daddr=".$vadd;?> target="_blank" ><u><?php echo $row['Venue'];?><u></a>
</td>
<td>
<?php echo $row[ 'EDate']. ' '.$time;?>
</td>
<!-- <td><div id="remain"><?php echo "$days, $hours:$minutes:$seconds";?></div></td> -->
<td> <a class="icon1" href=<?php echo "update.php?idno=".$eid;?>><span class="glyphicon glyphicon-pencil pencil"></span></a><a class="icon2" href="#myModal2" data-toggle="modal"><span class="glyphicon glyphicon-trash trash"></span></a>
</td>
</tr>
<?php $count++;
Make your target="_blank" first then give your href="link" as given below and close the underline tag </u>.
Try the following code:
<tr>
<td><?php echo $count;?></td>
<td ><a class="oiu" href=<?php echo "eventdetail.php?idno=".$row['E_id'];?>><u><?php echo $row['E_name'];?></u></a></td>
<td><a class="oiu" target="_blank" href=<?php echo "http://maps.google.com/maps?saddr=".$cadd."&daddr=".$vadd;?> ><u><?php echo $row['Venue'];?></u></a></td>
<td><?php echo $row['EDate'].' '.$time;?></td>
<!-- <td><div id="remain"><?php echo "$days, $hours:$minutes:$seconds";?></div></td> -->
<td> <a class="icon1" href=<?php echo "update.php?idno=".$eid;?>><span class="glyphicon glyphicon-pencil pencil"></span></a><a class="icon2" href="#myModal2" data-toggle="modal"><span class="glyphicon glyphicon-trash trash"></span></a></td>
</tr>
I am trying to get a radio button checked based on the data that was passed from the server to the view. However I cannot get the radio button to be checked inside a bootstrap table. The following is my code:
<tbody>
<?php
foreach($results as $row)
{
?>
<tr>
<td><?php echo $row->productCoverNoteNo ?></td>
<td><?php echo $row->productClass ?></td>
<td><?php echo $row->productName ?></td>
<td><?php echo $row->productPolicyNo ?></td>
<td>
<input type="radio" name="tbx_paymentStatus" id="paid" value="PAID" <?php if ($row->productPaymentStatus == "UNPAID"){ echo "checked='checked'"; }?> />
<label for="paid">Paid</label></br>
<input type="radio" name="tbx_paymentStatus" id="unpaid" value="UNPAID" <?php if ($row->productPaymentStatus == "PAID"){ echo "checked='checked'"; }?> />
<label for="unpaid">Unpaid</label>
</td>
<td><a title="Edit this customer product" href="<?php echo base_url("customerProduct/editCustomerProduct/$row->productCoverNoteNo") ?>"><i class="fa fa-pencil fa-lg"></i></a>
| <a title="View endorsements of this customer product" href="<?php echo base_url("endorsement/viewEndorsement/$row->productCoverNoteNo") ?>"><i class="fa fa-book fa-lg"></i></a></td>
</tr>
<?php echo($row->productPaymentStatus);
}
?>
</tbody>
Try this:
<input type="radio" name="tbx_paymentStatus" id="paid" value="PAID"
<?php if ($row->productPaymentStatus == "UNPAID"){ ?> checked='checked' <?php }?> />