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.
Related
I've been working on this codeigniter php app for my class and I have a view where you can select a quantity of a coin and the selected quantity comes back as a null.
my controller:
public function add(){
$this->form_validation->set_rules('quantity', 'Quantity', 'required');
if(!$this->session->userdata('logged_in')){
redirect('users/login');
}
$inventorycoin = $this->uri->segment('3');
$inventoryquantity = $this->input->post('quantity');
$this->coin_model->add_coin($inventorycoin, $inventoryquantity);
//$this->session->set_flashdata('post_deleted', 'Post has been deleted');
redirect('coins');
}
my model:
public function add_coin($inventorycoin, $inventoryquantity){
$data = array (
'inventory_user' => $this->session->userdata('user_id'),
'inventory_quantity' => $inventoryquantity,
'inventory_coin' => $inventorycoin
);
return $this->db->insert('inventory', $data);
}
my view:
<?php echo form_open_multipart('coins/add', 'id="coins"'); ?>
<table width="100%">
<?php foreach($coins as $coin) : ?>
<tr>
<td><img class="post-thumbnail" style="width: 200px; height: 200px" src="<?php echo site_url(); ?>assets/images/coins/<?php echo $coin['coin_image']; ?>"></td>
<td><?php echo $coin['coin_name']; ?></td>
<td><?php echo $coin['coin_country']; ?></td>
<td><?php echo $coin['coin_weight']; ?></td>
<td><input type="number" min="0" name="quantity" placeholder="Qt" style="width: 40px"></td>
<td><p><a class="btn btn-primary" href="<?php echo base_url(); ?>coins/add/<?php echo $coin['coin_id']; ?>">Add</a></p></td>
</tr>
<?php endforeach; ?>
</table>
</form>
What could be the problem?
You don't use submit button. So this part won't work.
$inventoryquantity = $this->input->post('quantity');
You are looping the input .So try to change your form to this.
<?php echo form_open_multipart('coins/add/', 'id="coins"'); ?>
<table width="100%">
<?php foreach($coins as $coin) : ?>
<tr>
<input name="inventorycoin[]" type="hidden" value = "<?=$coin['coin_id'];?>" >
<td><img class="post-thumbnail" style="width: 200px; height: 200px" src="<?php echo site_url(); ?>assets/images/coins/<?php echo $coin['coin_image']; ?>"></td>
<td><?php echo $coin['coin_name']; ?></td>
<td><?php echo $coin['coin_country']; ?></td>
<td><?php echo $coin['coin_weight']; ?></td>
<td><input type="number" min="0" name="quantity[]" placeholder="Qt" style="width: 40px"></td>
<td>--</td>
</tr>
<?php endforeach; ?>
</table>
<button type="submit"> Add </button>
</form>
and your function to this
public function add(){
$this->form_validation->set_rules('quantity', 'Quantity', 'required');
if(!$this->session->userdata('logged_in')){
redirect('users/login');
}
$inventorycoin = $this->input->post('inventorycoin');
$inventoryquantity = $this->input->post('quantity');
echo "<pre>";print_r($inventorycoin);
echo "<pre>";print_r($inventoryquantity); // you need to loop this because it is an array
redirect('coins');
}
You can change the below line in the view:
<td><p><a class="btn btn-primary" href="<?php echo base_url(); ?>coins/add/<?php echo $coin['coin_id']; ?>">Add</a></p></td>
Into this and try.
<td><p><a type="submit" class="btn btn-primary" href="<?php echo base_url('coins/add/'.$coin['coin_id']); ?>">Add</a></p></td>
I want to display a columns with radio buttons based on a data from mysql table and using php , but I am not able to toggle between the radio buttons. Below is the code.
while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ ?>
<tr>
<td border="0" type="hidden" style="display:none;"><input type="hidden" name="hidden" value=<?php echo $rows['member_id']; ?></td>
<td class="center"><?php echo $rows['username']; ?></td>
<td class="center"><?php echo $rows['email']; ?></td>
<?PHP if($_SESSION['user_group'] == 63){
echo '<td class="center"><input type="radio" id='?><?php echo $rows['username']; 'name="gp" value="system admin"' ?>
<?php echo ($rows['permission']== 31 )?'checked':'' ?>'</input> </td>' <?PHP ;
echo '<td class="center"><input type="radio" id='?><?php echo $rows['username']; 'name="gp" value="admin"' ?>
<?php echo($rows['permission']== 15 )?'checked':'' ?> '</input> </td>' <?PHP ;
echo '<td class="center"><input type="radio" id='?><?php echo $rows['username'];'name="gp" value="user"'
?><?php echo ($rows['permission']== 1 )?'checked':'' ?> '</input> </td>' <?PHP ; }
elseif($_SESSION['user_group'] == 31){
echo '<td class="center"><input type="radio" id='?><?php echo $rows['username']; 'name="gp" value="admin"' ?>
<?php echo($rows['permission']== 15 )?'checked':'' ?> '</input> </td>' <?PHP ;
echo '<td class="center"><input type="radio" id='?><?php echo $rows['username'];'name="gp" value="user"'
?><?php echo ($rows['permission']== 1 )?'checked':'' ?> '</input> </td>' <?PHP ; }
elseif($_SESSION['user_group'] == 15){
echo '<td class="center"><input type="radio" id='?><?php echo $rows['username'];'name="gp" value="user"'
?><?php echo ($rows['permission']== 1 )?'checked':'' ?> '</input> </td>' <?PHP ; }?>
<td class="center"><button name="update" type="update">submit</button></td>
</tr>
<?php
}
looks like there is an error in the code. Any help with it. The current rendition is below.
I want to toggle between the radio buttons.
was able to figure it out. Deleted echo command from the beginning of the html column lines. the code is presented below.
while($rows = $stmt->fetch(PDO::FETCH_ASSOC)){ ?>
<tr>
<td border="0" type="hidden" style="display:none;"><input type="hidden" name="hidden" value=<?php echo $rows['member_id']; ?></td>
<td class="center"><?php echo $rows['username']; ?></td>
<td class="center"><?php echo $rows['email']; ?></td>
<?PHP if($_SESSION['user_group'] == 63){ ?>
<td class="center"><input type='radio' id=<?php echo $rows['username']; ?> name="gp" value="system admin"
<?php echo ($rows['permission']== 31 )?'checked':'' ?>></input> </td>
<td class="center"><input type='radio' id=<?php echo $rows['username']; ?> name="gp" value="admin"
<?php echo ($rows['permission']== 15 )?'checked':'' ?> ></input> </td>
<td class="center"><input type='radio' id=<?php echo $rows['username']; ?> name="gp" value="user"
<?php echo ($rows['permission']== 1 )?'checked':'' ?> ></input> </td> <?PHP }
elseif($_SESSION['user_group'] == 31){ ?>
<td class="center"><input type='radio' id=<?php echo $rows['username']; ?> name="gp" value="admin"
<?php echo ($rows['permission']== 15 )?'checked':'' ?> ></input> </td>
<td class="center"><input type='radio' id=<?php echo $rows['username']; ?> name="gp" value="user"
<?php echo ($rows['permission']== 1 )?'checked':'' ?> ></input> </td> <?PHP }
elseif($_SESSION['user_group'] == 15){ ?>
<td class="center"><input type='radio' id=<?php echo $rows['username']; ?> name="gp" value="user"
<?php echo ($rows['permission']== 1 )?'checked':'' ?> ></input> </td><?PHP }?>
This worked just fine.
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 }?> />
I am encountering a problem when printing out the array that is stored inside $description.
Here is my code:
<?php foreach($descriptions as $description) { foreach ($languages as $language) { ?>
<div class="tabs-add language_id_<?php echo $language['language_id']; ?>" id="tab-language-<?php echo $module_row; ?>-<?php echo $language['language_id']; ?>">
<table id="general" class="form">
<tr>
<td><?php echo $entry_title; ?></td>
<td><input type="text" name="announcement_module[<?php echo $module_row; ?>][title][<?php echo $language['language_id']; ?>]" id="title-<?php echo $module_row; ?>-<?php echo $language['language_id']; ?>" value="<?php echo isset($module['title'][$language['language_id']]) ? $module['title'][$language['language_id']] : ''; ?>" /></td>
</tr>
<tr>
<td><?php echo $entry_description; ?> <a onclick="removeMessage(this);"><?php echo $button_remove; ?></a></td>
<td><textarea name="announcement_module[<?php echo $module_row; ?>][description][<?php echo $description_row;?>][<?php echo $language['language_id']; ?>]" id="description-<?php echo $module_row; ?>-<?php echo $description_row;?>-<?php echo $language['language_id']; ?>"><?php echo isset($module['description'][$description_row][$language['language_id']]) ? $module['description'][$description_row][$language['language_id']] : ''; ?></textarea></td>
</tr>
</table>
</div>
I want to print out the $entry_description as many times the user wants. But I can't seem to print out more than one at a time. How do I solve this?
I have two menus in php that uses stored procedure. Let's name it Menu1 and Menu2. This code this for Menu1: This is also the code for Menu 2.
<?php
$sql=$mysqli->query("call selectproducts()");
$i=1;
while($row=mysqli_fetch_array($sql)){
$id=$row['prodid'];
$date=$row['prodname'];
$item=$row['proddescription'];
$qtyleft=$row['prodsupplier'];
$qty_sold=$row['proddate'];
$price=$row['prodprice'];
$sales=$row['prodquantity'];
if($i%2){
?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<?php } else { ?>
<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
<?php } ?>
<td class="edit_td">
<span class="text"><?php echo $date; ?></span>
</td>
<td>
<span class="text"><?php echo $item; ?></span>
</td>
<td>
<span class="text"><?php echo $qtyleft; ?></span>
</td>
<td>
<span id="last_<?php echo $id; ?>" class="text">
<?php
echo $qty_sold;
?>
</span>
<input type="text" value="<?php echo $rtrt; ?>" class="editbox" id="last_input_<?php echo $id; ?>"/>
</td>
<td>
<span id="first_<?php echo $id; ?>" class="text"><?php echo $price; ?></span>
<input type="text" value="<?php echo $price; ?>" class="editbox" id="first_input_<?php echo $id; ?>" />
</td>
<td>
<span class="text"><?php echo $dailysales; ?>
<?php
echo $sales;
?>
</span>
</td>
</tr>
<?php
$i++;
}
?>
My Problem is when i call stored procedure in Menu1 it works, but in Menu2 it has error.
Based on my research, this code might has error because I am calling the stored procedure sequentially.
How to modify this code to be able to call the stored procedure the second time around? I'm really confused with this one. It seems like I need to close the stored procedure after the execution of first before I can call stored procedure again. I really don't know how to do this.
I'm guessing that you're getting an "out of sync" error?
You need to release resources by calling close() on your result set before you can make another call to the database on the same connection. Since you named your result variable $sql, you need to make a call $sql->close().
For example:
<?php
if( $result = $mysqli->query( "call selectproducts()" ) ) {
$i = 1;
while( $row=mysqli_fetch_array( $result ) ) {
$id=$row[ 'prodid' ];
$date=$row[ 'prodname' ];
$item=$row[ 'proddescription' ];
$qtyleft=$row[ 'prodsupplier' ];
$qty_sold=$row[ 'proddate' ];
$price=$row[ 'prodprice' ];
$sales=$row[ 'prodquantity' ];
if( $i % 2 ) {
?>
<tr id="<?php echo $id; ?>" class="edit_tr">
<?php
} else {
?>
<tr id="<?php echo $id; ?>" bgcolor="#f2f2f2" class="edit_tr">
<?php
}
?>
<td class="edit_td"><span class="text"><?php echo $date; ?></span></td>
<td><span class="text"><?php echo $item; ?></span></td>
<td><span class="text"><?php echo $qtyleft; ?></span></td>
<td>
<span id="last_<?php echo $id; ?>" class="text">
<?php echo $qty_sold; ?>
</span>
<input type="text" value="<?php echo $rtrt; ?>" class="editbox" id="last_input_<?php echo $id; ?>"/>
</td>
<td>
<span id="first_<?php echo $id; ?>" class="text"><?php echo $price; ?></span>
<input type="text" value="<?php echo $price; ?>" class="editbox" id="first_input_<?php echo $id; ?>" />
</td>
<td>
<span class="text"><?php echo $dailysales; ?><?php echo $sales; ?></span>
</td>
</tr>
<?php
$i++;
}
$result->close();
}
?>