Display only one name for there respective details - php

[1] => Array
(
[spid] => 21
[name] => Gaurav
[partner_acc_name] => SkyTechMasters
)
[2] => Array
(
[spid] => 21
[name] => Gaurav
[partner_acc_name] => TestPartner
)
This is the array i have show above.
i want that the "Gaurav" name should be display one for the "Partner_acc_name".
Code-
<tr class="all_partner" for="<?php echo $get_partner_forecast_val['spid']; ?>">
<td for="<?php echo $get_partner_forecast_val['spid']; ?>"rowspan="<?php echo ($product_no*2)+2; ?>"><?php echo $get_partner_forecast_val['name'];?></td>
<td for="<?php echo $get_partner_forecast_val['spid']; ?>"rowspan="<?php echo ($product_no*2)+2; ?>"><?php echo $get_partner_forecast_val['partner_acc_name'];?></td>
<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>"><?php echo $get_partner_forecast_val['crm_acc_name'];?></td>
This is the code.

well i solve this answer now with the help of Jquery.

Try this:
<?php
$temp = array();
foreach($partner_forecast as $get_partner_forecast_val) {
?>
<tr class="all_partner" for="<?php echo $get_partner_forecast_val['spid']; ?>">
<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>">
<?php if(!in_array($get_partner_forecast_val['name'], $temp)) echo $get_partner_forecast_val['name'];?>
</td>
<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>">
<?php echo $get_partner_forecast_val['partner_acc_name'];?>
</td>
<td for="<?php echo $get_partner_forecast_val['spid']; ?>" rowspan="<?php echo ($product_no*2)+2; ?>">
<?php echo $get_partner_forecast_val['crm_acc_name'];?>
</td>
</tr>
<?php
if(!in_array($get_partner_forecast_val['name'], $temp))
temp[] = $get_partner_forecast_val['name']; // add name to array which has been displayed so that we can check in next record whether its nedd to diaply or not
}
?>

Related

I cant delete Woocommerce rest api product from form

I create delete form but no delete with woocommerce rest api error"Warning: http_build_query() expects parameter 1 to be array, string given in" and "C:\xampp\htdocs\api-woocommerce\vendor\automattic\woocommerce\src\WooCommerce\HttpClient\HttpClient.php on line 138"
I dont understad.I can share form and php code;
<?php $i = 1; ?>
<?php foreach ( $data as $row ) : ?>
<tr>
<td><?= $i; ?></td>
<td>
<?= $row['id']; ?>
</td><td>
<?= $row['name']; ?>
</td><td>
<?= $row['permalink']; ?>
</td>
</td>
<td><?= $row['date_created']; ?></td>
<td><?= $row['status']; ?></td>
<td><?= $row['price']; ?></td>
<td><form action="delete_connect.php" name="delete" method="GET">
<input type="checkbox" name="id" value="<?= $row['id']; ?>"/>
</td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
<td><input type="submit" name="gönder"/></td></form>
and delete_connect.php;
<?php
$PRODUCT_ID = $_GET['id'];
?>
<?php echo json_encode($woocommerce->delete('products/',$PRODUCT_ID,['force' => true])); ?>
Try changing
<?php echo json_encode($woocommerce->delete('products/',$PRODUCT_ID,['force' => true])); ?>
to
<?php echo json_encode($woocommerce->delete('products/'.$PRODUCT_ID,['force' => true])); ?>
assuming your using this
https://woocommerce.github.io/woocommerce-rest-api-docs/?php#delete-a-product

Getting extra blank spaces while printing table

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.

how to print file path location in imce drupal?

i want display the file location path in the imce :
i opened the imce-file-list.tpl.php and i found that :
<tr id="<?php print $raw = rawurlencode($file['name']); ?>">
<td class="name"><?php print $raw; ?></td>
<td class="size" id="<?php print $file['size']; ?>"><?php print format_size($file['size']); ?></td>
<td class="width"><?php print $file['width']; ?></td>
<td class="height"><?php print $file['height']; ?></td>
<td class="date" id="<?php print $file['date']; ?>"><?php print format_date($file['date'], 'short'); ?></td>
</tr>
i want print $file[path] but it not working
Salaktarus,
Try use $imce['furl'] variable.
From drupal.org/node/1738218#comment-10674360

Foreach loop using 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?

PHP Stored Procedure error when calling sequentially or more than once

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();
}
?>

Categories