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 }?> />
Related
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>
So inside my table before tbody tag, I inserted a form inside tbody. However while submitting its form, the url is getting btnchange.php?qty=1 instead of btnchange.php?prod_id=cartno.
shopcart.php
<?php // start
$stmt = $DB_con->prepare("SELECT * FROM cart WHERE cartuser = '$userid' and cartpend='IN CART'");
$stmt->execute();
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row); //end ?>
<form method="get" action="btnchange.php?prod_id=<?php echo $row['cartno'] ?>">
<tbody>
<tr>
<td><?php echo $row['cartno']; ?></td>
<td><?php echo $row['cartname']; ?></td>
<td><?php echo $row['cartprice']; ?></td>
<td><input type="text" name="qty" value="<?php echo $row['cartqty']; ?>"></td>
<td><?php echo $row['cartsub']; ?></td>
<td><span class="label label-primary"><?php echo $row['cartpend']; ?></span></td>
<td><button type="submit" name="submit">Submit Quantity</button></b>
<td><a class="btn btn-danger btn-xs" href="?delete_id=<?php echo $row['cartno']; ?>" title="click for delete" onclick="return confirm('Sure to Delete?')"><i class="fa fa-trash-o"></i> Remove</a></td>
</tr>
</tbody>
</form>
This is my btnchange.php code, this is what i used to get the prod_id code and the qty input from shopcart.php.
btnchange.php
//get prod id
if(isset($_GET['prod_id']) && !empty($_GET['prod_id']))
{
$prod_code = $_GET['prod_id'];
$newqty = $_GET['qty'];
You can't put query parameters in the action attribute. You need to use a hidden input instead:
<?php // start
$stmt = $DB_con->prepare("SELECT * FROM cart WHERE cartuser = '$userid' and cartpend='IN CART'");
$stmt->execute();
if($stmt->rowCount() > 0)
{
while($row=$stmt->fetch(PDO::FETCH_ASSOC))
{
extract($row); //end ?>
<form method="get" action="btnchange.php">
<input type="hidden" name="prod_id" value="<?php echo $row['cartno']; ?>">
<tbody>
<tr>
<td><?php echo $row['cartno']; ?></td>
<td><?php echo $row['cartname']; ?></td>
<td><?php echo $row['cartprice']; ?></td>
<td><input type="text" name="qty" value="<?php echo $row['cartqty']; ?>"></td>
<td><?php echo $row['cartsub']; ?></td>
<td><span class="label label-primary"><?php echo $row['cartpend']; ?></span></td>
<td><button type="submit" name="submit">Submit Quantity</button></b>
<td><a class="btn btn-danger btn-xs" href="?delete_id=<?php echo $row['cartno']; ?>" title="click for delete" onclick="return confirm('Sure to Delete?')"><i class="fa fa-trash-o"></i> Remove</a></td>
</tr>
</tbody>
</form>
<?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']; ?>)
I have this code:
<table class="table table-bordered">
<thead>
<tr>
<th class="thheader">Monday</th>
<th class="thheader">Tuesday</th>
<th class="thheader">Wednesday</th>
<th class="thheader">Thursday</th>
<th class="thheader">Friday</th>
</tr>
</thead>
<?php
$available = array();
while ($row3 = mysqli_fetch_assoc($result3))
{
$dayt = $row3['day_of_week'];
$times = $row3['time_window_label'];
$tt= explode(",",$times);
$available[$dayt][] = trim($tt[1]);
}
for ($x=0; $x<3; $x++)
{
?>
<tr>
<td>
<center>
<?php
if($available[1][$x] != ''){
$counter++;?>
<input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value="<?php echo #$tt[1]?>" id="btn112<?php echo $counter;?>" /><label for="btn112<?php echo $counter;?>"> <i class="fa fa-check-circle hide12" id="chk-btn112<?php echo $counter;?>"></i> <?php echo #$available[1][$x];?></label>
<?php }?>
</center>
</td>
<td>
<center>
<?php if($available[2][$x] != ''){
$counter++;?>
<input type="checkbox" class="colour-button choice2 daypicker2" day="2" name="val2" value="<?php echo #$tt[1]?>" id="btn1012<?php echo $counter;?>" /><label for="btn1012<?php echo $counter;?>"> <i class="fa fa-check-circle hide13" id="chk-btn1012<?php echo $counter;?>"></i> <?php echo #$available[2][$x];?></label>
<?php }?>
</center>
</td>
<td>
<center>
<?php if($available[3][$x] != ''){
$counter++;?>
<input type="checkbox" class="colour-button choice3 daypicker3" day="3" name="val3" value="<?php echo #$tt[1]?>" id="btn102<?php echo $counter;?>" /><label for="btn102<?php echo $counter;?>"> <i class="fa fa-check-circle hide14" id="chk-btn102<?php echo $counter;?>"></i> <?php echo #$available[3][$x];?></label>
<?php }?>
</center>
</td>
<td>
<center>
<?php if($available[4][$x] != ''){
$counter++;?>
<input type="checkbox" class="colour-button choice4 daypicker4" day="4" name="val4" value="<?php echo #$tt[1]?>" id="btn1032<?php echo $counter;?>" /><label for="btn1032<?php echo $counter;?>"> <i class="fa fa-check-circle hide15" id="chk-btn1032<?php echo $counter;?>"></i> <?php echo #$available[4][$x];?></label>
<?php }?>
</center>
</td>
<td>
<center>
<?php if($available[5][$x] != ''){
$counter++;?>
<input type="checkbox" class="colour-button choice5 daypicker5" day="5" name="val5" value="<?php echo #$tt[1]?>" id="btn1042<?php echo $counter;?>" /><label for="btn1042<?php echo $counter;?>"> <i class="fa fa-check-circle hide16" id="chk-btn1042<?php echo $counter;?>"></i> <?php echo #$available[5][$x];?></label>
<?php }?>
</center>
</td>
</tr>
<?php }?>
</table>
It is inside a form, and when I click submit I want to be able to get the values that are in the form. The problem I'm facing is that my rows are dynamic, for example here is my outcome:
These are checkboxes, and the user is only allowed to pick one per day. However when I send the form this is how I tried getting the values:
$value1 = $_POST['val1'];
$value2 = $_POST['val2'];
$value3 = $_POST['val3'];
$value4 = $_POST['val4'];
$value5 = $_POST['val5'];
echo $value1;die;
However my output is only 5AM-8AM all the time, it is never 9AM-12PM even if I chose it. it is always the first time on the row. How can I fix this?
I am trying to print a table using Datatable Jquery , and it is giving me some extra spaces unnecessary.
<tbody>
<?php foreach($products as $product): ?>
<tr class="data-item show">
<td class="one wide tdalign collapsing">
<div id="divwhlprodmttrcheck" class="ui checkbox">
<input id="cbwhlprodmttrcheck" type="checkbox" name="inventory[]" value="<?php echo $product->productId ?>">
<label style="padding-left:0;"></label>
</div>
</td>
<td id="tdwhlprodmtin<?php echo $product->productId ?>" ><?php echo $product->ProductName ?></td>
<td id="tdwhlprodmtinsku<?php echo $product->productId ?>"><?php echo $product->SKU ?></td>
<td id="tdwhlprodmtincat<?php echo $product->productId ?>"><?php echo $product->Category ?></td>
<td id="tdwhlprodmtinsc<?php echo $product->productId ?>"><?php echo $product->Subcategory ?></td>
<td id="tdwhlprodmtinbr<?php echo $product->productId ?>"><?php echo $product->BrandName ?>
#if($product->BrandDeleted == 1)
<i class="warning red circle icon brand" data-content="Brand has been deleted" data-variation="inverted"></i>
#endif
</td>
<td id="tdwhlprodmtinsp<?php echo $product->productId ?>"><?php echo $product->SupplierName ?>
#if($product->SuppDeleted == 1)
<i class="warning red circle icon supp" data-content="Supplier has been deleted" data-variation="inverted"></i>
#endif
</td>
<td id="tdwhlprodmtinst<?php echo $product->productId ?>"><?php echo $product->AvailableStock ?></td>
<td id="tdwhlprodmtinpr<?php echo $product->productId ?>"><?php echo $product->Price ?></td>
#if($product->Discount == 0)
<td id="tdwhlprodmtinpr<?php echo $product->productId ?>">NA</td>
#else
<td id="tdwhlprodmtinpr<?php echo $product->productId ?>"><?php echo $product->Discount ?>%</td>
#endif
<input type="hidden" id="inhidsuppmain{{$product->productId}}" value="{{$product->SupplierName}}" >
<input type="hidden" id="inhidbrndmain{{$product->productId}}" value="{{$product->BrandName}}">
<input type="hidden" id="tdwhlprodmtprice<?php echo $product->productId?>" value="<?php echo $product->Price ?>" name="price">
<input type="hidden" id="inhiddiscountmain{{$product->productId}}" value="{{$product->Discount}}" >
<input type="hidden" id="inhidIsOnSalemain{{$product->productId}}" value="{{$product->onsale}}" >
<input type="hidden" id="inhidIsOnClearancemain{{$product->productId}}" value="{{$product->onclearance}}" >
<input type="hidden" name="inID" class="inid<?php echo $product->productId ?>" id="tdwhlprodmtinid<?php echo $product->productId ?>" value="<?php echo $product->productId; ?>">
<td class="tdalign collapsing"><i class="link black write icon" data-content="edit" data-variation="inverted" name="<?php echo $product->productId ?>" id="tdwhlprodmt<?php echo $product->productId; ?>" onclick="produps(4); getinValues('<?php echo $product->productId ?>'); gettingMulid('<?php echo $product->productId ?>')"></i>
</td>
</tr>
<?php endforeach; ?>
If I remove the code between <tbody> there is no spaces while code inside gives me spaces as below
I have even tried balancing it with margin-bottom , but no result yet.
Any help is appreciated.