If there is any error in bulk image uploader then see this file http://mssbuildingsupplies.co.uk/ $upload_directory = $_SERVER['DOCUMENT_ROOT']."/images/".$_GET['action']."/";
CSV Export
$header = "product_id,sku,name,cost,rrp,our_price,sale_price,clearance_price,supplier_gross_price,supplier_net_price\n"; $data = $header; $sql = "SELECT * FROM products ORDER BY product_id ASC"; $rs = mysql_query($sql); while($row = mysql_fetch_assoc($rs)){ $data .= $row['product_id'].",".$row['sku'].",".$row['name'].",".$row['cost'].",".$row['rrp'].",".$row['our_price'].",".$row['sale_price'].",".$row['clearance_price'].",".$row['supplier_gross_price'].",".$row['supplier_net_price']."\n"; } $file_name = "product_price.csv"; ob_clean(); echo $data; header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=$file_name"); header("Pragma: no-cache"); header("Expires: 0");
Auto Complete Searching
Php code for auto complete ————–
$product_name_string = array(); $query_result = $db->query("SELECT * FROM products ORDER BY name"); if($db->numRows($query_result)) { while($row = $db->next_record($query_result)){ //$product_name_string .='"'.trim($row['name']).'--'.$row['product_id'].'", '; array_push($product_name_string,array('label'=>$row['name'],'id'=>$row['product_id'])); } $_SESSION['product_name_string'] = $product_name_string; }
Jquery code for auto complete ——————
$(document).ready(function(){ ////////////////// Searching Medicine /////////////////////////////////////////// var availableProducts = <? echo json_encode($_SESSION['product_name_string']);?>; $(".search_text").live("focus", function() { $(".search_text").autocomplete({ source: availableProducts, delay: 0, minLength:1, select: function (event, ui) { productId = ui.item.id; $("#product_id").val(productId); } }); });
updating single field through ajax
javascript -------------> $('.update_invoice_button').click(function(){ var new_invoice_no = $(this).parent().find('.new_invoice_no').attr("value"); var fee_id = $(this).parent().find('.new_invoice_no').attr("width"); //return false; var form_data = {'table':'fee', 'where_column':'id', 'where_value':fee_id, 'update_column':'invoice_no', 'new_value':new_invoice_no }; $.ajax({ async: false, type: "POST", url: site_url+"/modules/reports/index.php?page=ajax_actions&action_page=update_field", data: form_data, success: function(result){ var resultObj = jQuery.parseJSON(result); alert(resultObj.message) } }); }); php on update_field --------------> <? $table = $_REQUEST['table']; $where_column = $_REQUEST['where_column']; $where_value = $_REQUEST['where_value']; $update_column = $_REQUEST['update_column']; $new_value = $_REQUEST['new_value']; $sql = "UPDATE $table SET $update_column ='$new_value' WHERE $where_column=$where_value "; $returnArray = array(); if(mysql_query($sql)){ $returnArray['status'] = "success"; $returnArray['message'] = ucfirst($update_column)." updated successfully"; }else{ $returnArray['status'] = "failure"; $returnArray['message'] = "Error in updating, please contact admin"; } echo json_encode($returnArray); die;
removing tag on php
strip_tags(content)
Facebox (colorbox) through css and html
Div which is shown on facebox------------- <div class="overlay" style="overflow: auto;"> <div class="confirmbox" style="margin: 3% auto;display:none;"> <span> <img style="cursor:pointer;float:right;" title="Close" onclick="javascript:close_overlay();" src="img/del.gif" border="0"> <div id='content_container'></div> </span> </div> </div> javascript <script type="text/javascript"> function close_overlay(){ $('.overlay').hide('slow'); } $(document).ready(function(){ $('.terms_link').live('click',function(){ var content = $(this).parent().find(".terms_link_data").html(); $('#content_container').html(content); $(".confirmbox").css('height','40%'); $(".confirmbox").css('width','40%'); $(".overlay").show('slow'); $(".confirmbox").css('display','block'); }); }); </script> html apply here------------ <td style='border:solid 1px #245F9B;' align="center" > <div style='display:none;' class="terms_link_data"> <? echo $data['comment'];?> </div> <a href='#' style='text-decoration:none;' class='terms_link'> <? echo ellipsis(ucfirst($data['comment']),50);?> </a> </td>
To add zero before a number
str_pad("12", 5, '0', STR_PAD_LEFT); result 00012
Mega menu
like http://www.argos.co.uk/static/Home.htm or http://www.econker.com/?new=1
mega-menu
sending mail with attach, bcc and cc
static function multi_attach_mail($to, $subject, $message_body, $files, $sendermail,$cc="",$bcc=""){ $message_body = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Edify Email</title><body>'.$message_body.'</body></head></html>'; // email fields: to, from, subject, and so on //$sendermail = "heenabhalla007@gmail.com"; $from = "<".$sendermail.">"; //$subject = date("d.M H:i")." F=".count($files); $message = date("Y.m.d H:i:s")."\n".count($files)." attachments"; $headers = "From: $from \r\n"; if($cc !=""){ //$cc = "<".$cc.">"; $headers .= "Cc: $cc \r\n"; } if($bcc !=""){ //$bcc = "<".$bcc.">"; $headers .= "Bcc: $bcc \r\n"; } $headers .= "Reply-To: $sendermail \r\n"; $headers .= "X-Mailer: PHP/".phpversion(); // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message_body . "\n\n"; // preparing attachments for($i=0;$i<count($files);$i++){ if(is_file($files[$i])){ $message .= "--{$mime_boundary}\n"; $fp = @fopen($files[$i],"rb"); $data = @fread($fp,filesize($files[$i])); @fclose($fp); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: application/octet-stream; name=\"".basename($files[$i])."\"\n" . "Content-Description: ".basename($files[$i])."\n" . "Content-Disposition: attachment;\n" . " filename=\"".basename($files[$i])."\"; size=".filesize($files[$i]).";\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } } $message .= "--{$mime_boundary}--"; $returnpath = "-f" . $sendermail; @mail($to, $subject, $message, $headers, $returnpath); }
multi delete
////////////////////////////// For deleting multiple row ///////////////////////////////////////////// $('.dependent_delete').live("click",function(){ if(confirm('Are you sure! You want to delete')){ var dependent_id = $(this).attr("title"); if(dependent_id){ var form_data = {'dependent_id' : dependent_id }; $.ajax({ async: false, type: "POST", url: site_url+"/modules/student/index.php?page=ajax_actions&action_page=delete_dependent_brp&action=delete", data: form_data, success: function(result){ //alert(result); //$('#dependent_'+dependent_id).remove(); } }); } $(this).parent().parent().remove(); } return false; });