PHP - Displaying Multiple Files With Seperate Topic Names
hmm im having some trouble tackling this problem
i have a database table with topicname then 3 columns with 3 pdfs in each one all the files are stored in a directory called topicfiles in the server so like 3 topicnames with 3 files in each one with this page i want to make i want to display each topic name with the files under it calling it from the server like Code: [Select] topic 1 file1.pdf file2.pdf file3.pdf topic 2 file4.pdf file5.pdf file6.pdf topic 3 file71.pdf file8.pdf file9.pdf i tried using dhandler to access all files in the folder and only managed to display all of the files in rows using foreach loop was thinkin of using mysql query to access the topic name and then each file for that topic but not sure hmmm Similar TutorialsI need to display multiple files that have a similar file name, but there are timestamps added to the filename once its been modified. What could I use in PHP to display all these files? Right now I use a $path variable that looks into a SQL table to build the path to the folder that the files reside in.. ELSEIF($Recordmyrow['Applicatio'] == "pdf file") { IF($securityvalue != "P"){$display = false;} IF(file_exists(substr($path, 5))){} ELSE{$column4 = "<A href='javascript:mbox();'>UNAVAILABLE</A>";} } So there is a file called file1.pdf then another one called file1.mmddyyyy.pdf My code shows file1.pdf but not file1.mmddyyyy.pdf Is there some kind of wildcard I can use to get it to show all the files if they exist? hey guys im getting my column names with this query: $query = mysql_query("SELECT column_name FROM information_schema.columns WHERE table_name = 'cam_systems'"); I then have an array: $fields = array( "cfg_change_date" => "Configuration Change Date", "system_name" => "System Name", "system_manf" => "System Manufacturer", "system_model_no" => "System Model Number", "system_serial_no" => "System Serial Number", "system_board_part_no" => "System Board Part Number", "system_board_serial_no" => "System Board Serial Number", "asset_tag" => "Asset Tag", "sla_code" => "SLA Code", "category" => "Category", "os_version" => "OS Version", "os_upgraded" => "OS Upgraded", "bios_version" => "BIOS Version", "bios_upgraded" => "BIOS Upgraded", "ilom_version" => "ILOM Version", "ilom_ip" => "ILOM IP Address", "ilom_updated" => "ILOM Updated", "rack_id" => "Rack ID", "rack_location_id" => "Rack Location ID", "tech_id" => "Tech ID", "warranty" => "Warranty" ); I need to display these field names now, but rather than the actual column name, I've created an array with column name and then the name I want to actual display. How can I do that? Is their a better way I should be doing this? Hello I have a problem. I have been trying to copy my music folders structure but not copying the mp3s; instead using the file names as a file name for a .txt file and inserting the URL to the file in the .txt file. Eg. E:\My Music folder 1 folder 1.1 file.mp3 folder 2 folder 3 to G:\My Music folder 1 folder 1.1 file.txt folder 2 folder 3 and inside "file.txt" would be one line saying "http://www.xxx.com/my_music/file.mp3 I am having trouble adding sub-topics to my home made blog system running under PHP-Fusion CMS with PHPver7.4.16 with cgi/fcgi interface and MySQL5.7.34-log. Here are 2 images: Here is the module that produces the output. <?php echo "<div class='col-sm-12'>\n"; echo "<table width='100%' border='0'><tr><td><span class='hdspan2'><b>".$locale['gb_810']."</b></span></td></tr></table>\n"; echo "<table align='center' width='80%' border='0'>\n"; $result = dbquery("SELECT * FROM ".DB_GRIMS_BLOG_TOPICS." ORDER BY topic_order ASC"); if (dbrows($result)) { $cnt = 0; while($data = dbarray($result)) { $id = $data['topic_id']; $title = $data['topic_title']; $sub = $data['topic_sub']; $result1 = dbquery("SELECT * FROM ".DB_GRIMS_BLOG_POST." WHERE topic_id='$id'"); $num_rows = dbrows($result1); if ($sub == '1') { echo "<tr><td width='15'></td><td><a class='lnk-side' href='".BASEDIR."grims_blog/topics_page.php?topic_id=".$id."'>$title</a><span style='font-size:11px;color:white;'> [$num_rows posts]</span></td></tr>\n"; } else { echo "<tr><td colspan='2'><a class='lnk-side' href='".BASEDIR."grims_blog/topics_page.php?topic_id=".$id."'>$title</a><span style='font-size:11px;color:white;'> [$num_rows posts]</span></td></tr>\n"; } } $cnt++; } echo "</table><p></div>\n"; ?> The topic_order field is a new field I added to get the desired output but it's not standard procedure and is in fact not really workable in a live setting because I would have to use php_myadmin to modify it everytime I added or deleted a topic or sub-topic. So the bottom line is that I can't figure out anyway to code the script to always show the sub-topic right under the associated main topic and all in order. If I add a sub-topic to one of the upper main topics it shows up at the bottom; hence the addition of the topic_order field. So right now it's basically a mess and I can't figure out how to code everything to work correctly. I have searched the forums here as well as several other sites and cannot get any clues.
I can get files to upload to folder and add a new row for each in to a mysql db using the code below, how do I get all the filles in one row with multiple uploads Code: [Select] //Check if the form was submitted. if(isset($_POST['uploadButton'])) { //Specify folder path where the file is going. $path = 'uploads/'; //Upload file one by one. foreach($_FILES['file']['name'] as $key => $val) { if($val != '') { $file_name = $_FILES['file']['name'][$key]; //Get file name. $file_tmp = $_FILES['file']['tmp_name'][$key]; //Get temporary file name. $file = $path . $file_name; mysql_query("INSERT INTO images (img1) VALUES('$file');") or trigger_error('Unable to INsert: ' . mysql_error()); //Move uploaded file if(move_uploaded_file($file_tmp, $file)) { echo 'File was succesfully uploaded to: ' . $file . '<br />'; } else { //Display error message if there was a problem uploading file. echo 'Error uploading file "' . $key . '."<br />'; } echo $target_path; } } } ?> guys, I have looked on google for this and apparently noone is doing it. I have 4 checkboxes and I want to send mail indicating which boxes were checked. the only code I've found is PHP that captures the *status* of the boxes, such as "on" or "off". I want to capture the names of the actual checkbox elements. Here is the code I'm currently testing (which just prints out "on" or "off" to indicate which boxes are checked): if(isset($_POST['checkboxes'])) { foreach($_POST['checkboxes'] as $selected){ echo $selected . "</br>"; } } else { echo "No Desired Contact Time Specified."; } if I check all 4 boxes for instance, I get this: on on on on any way to get the names? thanks! I'm using a woocommerce order report plugin, some customers order multiple products but order report shows only number of order and one product name: I want to see all product names: also I want to see customer notes it doesn't show up
<?php /** * Plugin Name: Custom Order Report * Description: Generates a report on individual WooCommerce products sold during a specified time period. * Version: 1.4.8 */ // Add the Product Sales Report to the WordPress admin add_action('admin_menu', 'hm_psrf_admin_menu'); function hm_psrf_admin_menu() { add_submenu_page('woocommerce', 'Custom Order Report', 'Custom Order Report', 'view_woocommerce_reports', 'hm_sbpf', 'hm_sbpf_page'); } function hm_psrf_default_report_settings() { return array( 'report_time' => '30d', 'report_start' => date('Y-m-d', current_time('timestamp') - (86400 * 31)), 'report_end' => date('Y-m-d', current_time('timestamp') - 86400), 'order_statuses' => array('wc-processing', 'wc-on-hold', 'wc-completed'), 'products' => 'all', 'product_cats' => array(), 'product_ids' => '', 'variations' => 0, 'orderby' => 'quantity', 'orderdir' => 'desc', 'fields' => array('product_id', 'product_sku', 'product_name', 'quantity_sold', 'gross_sales'), 'limit_on' => 0, 'limit' => 10, 'include_header' => 1, 'exclude_free' => 0 ); } // This function generates the Product Sales Report page HTML function hm_sbpf_page() { $savedReportSettings = get_option('hm_psr_report_settings'); if (isset($_POST['op']) && $_POST['op'] == 'preset-del' && !empty($_POST['r']) && isset($savedReportSettings[$_POST['r']])) { unset($savedReportSettings[$_POST['r']]); update_option('hm_psr_report_settings', $savedReportSettings); $_POST['r'] = 0; echo('<script type="text/javascript">location.href = location.href;</script>'); } $reportSettings = (empty($savedReportSettings) ? hm_psrf_default_report_settings() : array_merge(hm_psrf_default_report_settings(), $savedReportSettings[ isset($_POST['r']) && isset($savedReportSettings[$_POST['r']]) ? $_POST['r'] : 0 ] )); // For backwards compatibility with pre-1.4 versions if (!empty($reportSettings['cat'])) { $reportSettings['products'] = 'cats'; $reportSettings['product_cats'] = array($reportSettings['cat']); } $fieldOptions = array( 'order_id' => 'Order ID', /*'product_id' => 'Product ID',*/ 'customer_name' => 'Customer Name', /*'variation_id' => 'Variation ID',*/ 'city' => 'City', 'address' => 'Address', 'product_name' => 'Product Name', 'quantity_sold' => 'Quantity Sold', /*'product_sku' => 'Product SKU',*/ 'gross_sales' => 'Gross Sales', 'product_categories' => 'Schools', /*'variation_attributes' => 'Variation Attributes',*/ /*'gross_after_discount' => 'Gross Sales (After Discounts)'*/ 'ceremony_date' => 'Ceremony Date', 'ceremony_time' => 'Ceremony Time', ); include(dirname(__FILE__).'/admin.php'); } // Hook into WordPress init; this function performs report generation when // the admin form is submitted add_action('init', 'hm_sbpf_on_init', 9999); function hm_sbpf_on_init() { global $pagenow; // Check if we are in admin and on the report page if (!is_admin()) return; if ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'hm_sbpf' && !empty($_POST['hm_sbp_do_export'])) { // Verify the nonce check_admin_referer('hm_sbpf_do_export'); $newSettings = array_intersect_key($_POST, hm_psrf_default_report_settings()); foreach ($newSettings as $key => $value) if (!is_array($value)) $newSettings[$key] = htmlspecialchars($value); // Update the saved report settings $savedReportSettings = get_option('hm_psr_report_settings'); $savedReportSettings[0] = array_merge(hm_psrf_default_report_settings(), $newSettings); update_option('hm_psr_report_settings', $savedReportSettings); // Check if no fields are selected or if not downloading if (empty($_POST['fields']) || empty($_POST['hm_sbp_download'])) return; // Assemble the filename for the report download $filename = 'Product Sales - '; if (!empty($_POST['cat']) && is_numeric($_POST['cat'])) { $cat = get_term($_POST['cat'], 'product_cat'); if (!empty($cat->name)) $filename .= addslashes(html_entity_decode($cat->name)).' - '; } $filename .= date('Y-m-d', current_time('timestamp')).'.csv'; // Send headers header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); // Output the report header row (if applicable) and body $stdout = fopen('php://output', 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($stdout); hm_sbpf_export_body($stdout); exit; } } // This function outputs the report header row function hm_sbpf_export_header($dest, $return=false) { $header = array(); foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $header[] = 'Order ID'; break; case 'product_name': $header[] = 'Product Name'; break; case 'quantity_sold': $header[] = 'Quantity Sold'; break; case 'gross_sales': $header[] = 'Gross Sales'; break; case 'product_categories': $header[] = 'Schools'; break; case 'customer_name': $header[] = 'Customer Name'; break; case 'city': $header[] = 'City'; break; case 'address': $header[] = 'Address'; break; case 'ceremony_date': $header[] = 'Ceremony Date'; break; case 'ceremony_time': $header[] = 'Ceremony Time'; break; } } if ($return) return $header; fputcsv($dest, $header); } // This function generates and outputs the report body rows function hm_sbpf_export_body($dest, $return=false) { global $woocommerce, $wpdb; $product_ids = array(); if ($_POST['products'] == 'cats') { $cats = array(); foreach ($_POST['product_cats'] as $cat) if (is_numeric($cat)) $cats[] = $cat; $product_ids = get_objects_in_term($cats, 'product_cat'); } else if ($_POST['products'] == 'ids') { foreach (explode(',', $_POST['product_ids']) as $productId) { $productId = trim($productId); if (is_numeric($productId)) $product_ids[] = $productId; } } // Calculate report start and end dates (timestamps) switch ($_POST['report_time']) { case '0d': $end_date = strtotime('midnight', current_time('timestamp')); $start_date = $end_date; break; case '1d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date; break; case '7d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 6); break; case '1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight -1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '0cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight +1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+7d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 6); break; case '+30d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 29); break; case 'custom': $end_date = strtotime('midnight', strtotime($_POST['report_end'])); $start_date = strtotime('midnight', strtotime($_POST['report_start'])); break; default: // 30 days is the default $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 29); } // Assemble order by string $orderby = (in_array($_POST['orderby'], array('product_id', 'gross', 'gross_after_discount')) ? $_POST['orderby'] : 'quantity'); $orderby .= ' '.($_POST['orderdir'] == 'asc' ? 'ASC' : 'DESC'); // Create a new WC_Admin_Report object include_once($woocommerce->plugin_path().'/includes/admin/reports/class-wc-admin-report.php'); $wc_report = new WC_Admin_Report(); $wc_report->start_date = $start_date; $wc_report->end_date = $end_date; //echo(date('Y-m-d', $end_date)); $where_meta = array(); if ($_POST['products'] != 'all') { $where_meta[] = array( 'type' => 'order_item_meta', 'meta_key' => '_product_id', 'operator' => 'in', 'meta_value' => $product_ids ); } if (!empty($_POST['exclude_free'])) { $where_meta[] = array( 'meta_key' => '_line_total', 'meta_value' => 0, 'operator' => '!=', 'type' => 'order_item_meta' ); } // Get report data // Avoid max join size error $wpdb->query('SET SQL_BIG_SELECTS=1'); // Prevent plugins from overriding the order status filter add_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); // Based on woocoommerce/includes/admin/reports/class-wc-report-sales-by-product.php $sold_products = $wc_report->get_order_report_data(array( 'data' => array( '_product_id' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'product_id' ), '_qty' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'quantity' ), '_line_subtotal' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross' ), '_line_total' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross_after_discount' ), /*usama*/ 'order_id' => array( 'type' => 'order_item', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'order_id' ) /*usama*/ ), 'query_type' => 'get_results', 'group_by' => 'order_id', 'where_meta' => $where_meta, 'order_by' => $orderby, 'limit' => (!empty($_POST['limit_on']) && is_numeric($_POST['limit']) ? $_POST['limit'] : ''), 'filter_range' => ($_POST['report_time'] != 'all'), 'order_types' => wc_get_order_types('order_count'), 'order_status' => hm_psrf_report_order_statuses() )); // Remove report order statuses filter remove_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); if ($return) $rows = array(); // Output report rows foreach ($sold_products as $product) { $row = array(); /*usama*/ $order = wc_get_order($product->order_id); $customerName = $order->get_billing_first_name().' '.$order->get_billing_last_name(); $billingCity = $order->get_billing_city(); $billingAddress1 = $order->get_billing_address_1(); //echo $product->order_id; //echo $customerName.$city.$billingAddress1; //echo '<pre>';print_r($order);exit; /*usama*/ foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $row[] = $product->order_id; break; case 'product_name': $row[] = html_entity_decode(get_the_title($product->product_id)); break; case 'quantity_sold': $row[] = $product->quantity; break; case 'gross_sales': $row[] = $product->gross; break; /*case 'variation_id': $row[] = (empty($product->variation_id) ? '' : $product->variation_id); break; case 'product_sku': $row[] = get_post_meta($product->product_id, '_sku', true); break;*/ case 'product_categories': $terms = get_the_terms($product->product_id, 'product_cat'); if (empty($terms)) { $row[] = ''; } else { $categories = array(); foreach ($terms as $term) $categories[] = $term->name; $row[] = implode(', ', $categories); } break; case 'customer_name': $row[] = $customerName; break; case 'city': $row[] = $billingCity; break; case 'address': $row[] = $billingAddress1; break; /*case 'gross_after_discount': $row[] = $product->gross_after_discount; break;*/ /*usama*/ case 'ceremony_date': $row[] = $order->get_meta( '_billing_myfield12', true ); break; case 'ceremony_time': $row[] = $order->get_meta( '_billing_myfield13', true ); break; } } if ($return) $rows[] = $row; else fputcsv($dest, $row); } if ($return) return $rows; } add_action('admin_enqueue_scripts', 'hm_psrf_admin_enqueue_scripts'); function hm_psrf_admin_enqueue_scripts() { wp_enqueue_style('hm_psrf_admin_style', plugins_url('css/hm-product-sales-report.css', __FILE__)); wp_enqueue_style('pikaday', plugins_url('css/pikaday.css', __FILE__)); wp_enqueue_script('moment', plugins_url('js/moment.min.js', __FILE__)); wp_enqueue_script('pikaday', plugins_url('js/pikaday.js', __FILE__)); } // Schedulable email report hook add_filter('pp_wc_get_schedulable_email_reports', 'hm_psrf_add_schedulable_email_reports'); function hm_psrf_add_schedulable_email_reports($reports) { $reports['hm_psr'] = array( 'name' => 'Product Sales Report', 'callback' => 'hm_psrf_run_scheduled_report', 'reports' => array( 'last' => 'Last used settings' ) ); return $reports; } function hm_psrf_run_scheduled_report($reportId, $start, $end, $args=array(), $output=false) { $savedReportSettings = get_option('hm_psr_report_settings'); if (!isset($savedReportSettings[0])) return false; $prevPost = $_POST; $_POST = $savedReportSettings[0]; $_POST['report_time'] = 'custom'; $_POST['report_start'] = date('Y-m-d', $start); $_POST['report_end'] = date('Y-m-d', $end); $_POST = array_merge($_POST, array_intersect_key($args, $_POST)); if ($output) { echo('<table><thead><tr>'); foreach (hm_sbpf_export_header(null, true) as $heading) { echo("<th>$heading</th>"); } echo('</tr></thead><tbody>'); foreach (hm_sbpf_export_body(null, true) as $row) { echo('<tr>'); foreach ($row as $cell) echo('<td>'.htmlspecialchars($cell).'</td>'); echo('</tr>'); } echo('</tbody></table>'); $_POST = $prevPost; return; } $filename = get_temp_dir().'/Product Sales Report.csv'; $out = fopen($filename, 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($out); hm_sbpf_export_body($out); fclose($out); $_POST = $prevPost; return $filename; } function hm_psrf_report_order_statuses() { $wcOrderStatuses = wc_get_order_statuses(); $orderStatuses = array(); if (!empty($_POST['order_statuses'])) { foreach ($_POST['order_statuses'] as $orderStatus) { if (isset($wcOrderStatuses[$orderStatus])) $orderStatuses[] = substr($orderStatus, 3); } } return $orderStatuses; } /* Review/donate notice */ register_activation_hook(__FILE__, 'hm_psrf_first_activate'); function hm_psrf_first_activate() { $pre = 'hm_psr'; $firstActivate = get_option($pre.'_first_activate'); if (empty($firstActivate)) { update_option($pre.'_first_activate', time()); } } if (is_admin() && get_option('hm_psr_rd_notice_hidden') != 1 && time() - get_option('hm_psr_first_activate') >= (14*86400)) { add_action('admin_notices', 'hm_psrf_rd_notice'); add_action('wp_ajax_hm_psrf_rd_notice_hide', 'hm_psrf_rd_notice_hide'); } function hm_psrf_rd_notice() { $pre = 'hm_psr'; $slug = 'product-sales-report-for-woocommerce'; echo(' <div id="'.$pre.'_rd_notice" class="updated notice is-dismissible"><p>Do you use the <strong>Product Sales Report</strong> plugin? Please support our free plugin by <a href="" target="_blank">making a donation</a>!product-sales-report-for-woocommerce Thanks!</p></div> <script>jQuery(document).ready(function($){$(\'#'.$pre.'_rd_notice\').on(\'click\', \'.notice-dismiss\', function(){jQuery.post(ajaxurl, {action:\'hm_psrf_rd_notice_hide\'})});});</script> '); } function hm_psrf_rd_notice_hide() { $pre = 'hm_psr'; update_option($pre.'_rd_notice_hidden', 1); } ?>
Hi, I'm having a bit of a problem sharing some variables I have across a few files. My first file (index.php) calls an ajax request for (display.php) and sends a few variables to it. All fine so far. display.php then does its thing and displays the content on index.php as it should. Now in display.php I need a variable to be passed back to index.php for use in a menu. I've tried setting a session variable in display.php but unfortunately this doesn't seem to work. I also can't use get or post as I don't want to refresh the page. Really scratching my head over this one! Edd Hi Guys, I have a HTML form which posts to a PHP mail script page. This data then emails to the company email address. I have two file attachments on my form: CV and Photo ID How do I integrate my php mail script to upload and then email these TWO files as TWO attachements on the email? $fileatt_cv $fileatt_id I have tried a few methods that I found on Google but they dont work Code: [Select] <?php // Grab Data from Form if(isset($_POST['submit'])) { // Personal Information $surname = mysql_real_escape_string($_POST['surname']); $firstname = mysql_real_escape_string($_POST['firstname']); $telephone = mysql_real_escape_string($_POST['telephone']); $mobile = mysql_real_escape_string($_POST['mobile']); $email = mysql_real_escape_string($_POST['email']); $address = mysql_real_escape_string($_POST['address']); $postcodep1 = mysql_real_escape_string($_POST['postcodep1']); $postcodep2 = mysql_real_escape_string($_POST['postcodep2']); $dob_dd = mysql_real_escape_string($_POST['dob_dd']); $dob_mm = mysql_real_escape_string($_POST['dob_mm']); $dob_yyyy = mysql_real_escape_string($_POST['dob_yyyy']); // Next of Kin $nextkinname = mysql_real_escape_string($_POST['nextkinname']); $nextkintel = mysql_real_escape_string($_POST['nextkintel']); // Availability $days_mon = mysql_real_escape_string($_POST['days_mon']); $days_tue = mysql_real_escape_string($_POST['days_tue']); $days_wed = mysql_real_escape_string($_POST['days_wed']); $days_thu = mysql_real_escape_string($_POST['days_thu']); $days_fri = mysql_real_escape_string($_POST['days_fri']); $days_sat = mysql_real_escape_string($_POST['days_sat']); $days_sun = mysql_real_escape_string($_POST['days_sun']); $availability_am = mysql_real_escape_string($_POST['availability_am']); $availability_pm = mysql_real_escape_string($_POST['availability_pm']); $availability_allday = mysql_real_escape_string($_POST['availability_allday']); $availability_requirements = mysql_real_escape_string($_POST['availability_requirements']); // Experience $experience = mysql_real_escape_string($_POST['experience']); // File Attachments $fileatt_cv = mysql_real_escape_string($_POST['fileatt_cv']); $fileatt_id = mysql_real_escape_string($_POST['fileatt_id']); // Rates $rate = mysql_real_escape_string($_POST['rate']); $rate_specific = mysql_real_escape_string($_POST['rate_specific']); // Employer Ref $employrefname = mysql_real_escape_string($_POST['employrefname']); $employrefcomp = mysql_real_escape_string($_POST['employrefcomp']); $employreftel = mysql_real_escape_string($_POST['employreftel']); $employrefadd = mysql_real_escape_string($_POST['employrefadd']); // Personal Ref $persrefname = mysql_real_escape_string($_POST['persrefname']); $persreftel = mysql_real_escape_string($_POST['persreftel']); $persrefadd = mysql_real_escape_string($_POST['persrefadd']); // Extra Information $allergy = mysql_real_escape_string($_POST['allergy']); $allergy_details = mysql_real_escape_string($_POST['allergy_details']); $drive = mysql_real_escape_string($_POST['drive']); $car = mysql_real_escape_string($_POST['car']); $criminal = mysql_real_escape_string($_POST['criminal']); $criminal_details = mysql_real_escape_string($_POST['criminal_details']); $howlongworkuk = mysql_real_escape_string($_POST['howlongworkuk']); $police_check = mysql_real_escape_string($_POST['police_check']); $right2work = mysql_real_escape_string($_POST['right2work']); $right2workna = mysql_real_escape_string($_POST['right2workna']); // Email Options $subject = "Test Company - Job Application"; $to = "test@test.com"; $mailheader = "From: $email" . "\r\n"; $mailheader .= 'MIME-Version: 1.0' . "\r\n"; $mailheader .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Applicants copy $mailheader .= "BCc: $email" . "\r\n"; // Message Content $body .= 'Message'; // End of Email Content > Display Message echo "Thank you. Your application was submitted to us successly. We review all applications carefully and we may contact you shortly."; // Attempt to Send Email mail($to, $subject, $body, $mailheader); } else { echo "Application Failed. Unfortunatley, there was a problem with your application and it was not submitted. Please try again later or alternativley please contact us."; } ?> Thanks in advanced. Hi all, I was wondering if it was possible and not too messy to have a single form page (html) and have it post to 2 or more PHP files? Surely this is something that is desirable and accomplished at some point, right? Thanks. Richard I need to be able to upload multiple files with the use of one form. Right now I have support for one file and it works great. I am stuck on what route I should take for times sake and reliability and functionality. Can I run each file on its own through the PHP script to upload the file; I would have to create a loop to run through the script as many times as there are files. OR Do I create new functionality and add the files through the use of an array? This is where I am getting the ARRAY idea: http://www.phpeasystep.com/phptu/2.html This is the PHP code that is submitting the image and uploading to file system. This is what I would use to loop through multiple files if I take the loop method. <? header("location: /classifieds/index.php"); echo '<html><center>'; //first lets upload any files that were selected// $date = date("m/d/y",time()); //check that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 2500000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/uploads/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $newname); echo $tempnewname; $newname=$tempnewname[9].'/'.$tempnewname[10]; echo "It's done! The file has been saved as: ".$filename; } else { echo "Error: A problem occurred during file upload!"; } } else { //echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";// $timestampname = str_replace('.jpg', date('j-n-Y_g:i:s').'.jpg', (basename($_FILES['uploaded_file']['name']))); $path = dirname(__FILE__).'/uploads/'; $fullname = $path.$timestampname; //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $fullname); $newname=$tempnewname[7].'/'.$tempnewname[8]; $picname=$tempnewname[8]; ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))); } } else { echo "Error: Only .jpg images under 2.5MB are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> Thanks for hte help -Beemer Good day all. I am looking for guidence. I am using phpexcell to format an excell file. all working 100% What should i be looking to do when i want to edit and format multiple files in a directory. about 200 excell documents all the same and with same formatting? Found this code for reading, but lets say row c3:i3 i want bold and size 14 in all the excell files . . . $path = "..."; ///the folder path $theFilePath = ""; $theFileName = glob ($path . "*.xls"); //Read more than one file here for($j = 0; $j< count($theFileName); $j++) { $theFilePath = $theFileName[$j]; $excel = new Spreadsheet_Excel_Reader(); $excel->setOutputEncoding('CP1251'); $excel->setUTFEncoder('mb_convert_encoding'); error_reporting(E_ALL ^ E_NOTICE); //echo $theFileName[$j];; echo "<br />"; echo $theFilePath; echo "<br />"; $excel->read($theFilePath); . . .// Do what u want display here }
My Php Buddies, I have mysql tbl columns these:
id: Now, I want to display their row data by excluded a few columns. Want to exclude these columns: date_&_time account_activation_code account_activation_status id_verification_video_file_url password
So, the User's (eg. your's) homepage inside his account should display labels like these where labels match the column names but the underscores are removed and each words' first chars CAPITALISED:
Id: 1
For your convenience only PART 1 works. Need help on Part 2 My attempted code:
PART 1 <?php // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // Query to get columns from table $query = $conn->query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'members' AND TABLE_NAME = 'users'"); while($row = $query->fetch_assoc()){ $result[] = $row; } // Array of all column names $columnArr = array_column($result, 'COLUMN_NAME'); foreach ($columnArr as $value) { echo "<b>$value</b>: ";?><br><?php } ?> PART 2 <?php //Display User Account Details echo "<h3>User: <a href=\"user.php?user=$user\">$user</a> Details</h3>";?><br> <?php $excluded_columns = array("date_&_time","account_activation_code","account_activation_status","id_verification_video_file_url","password"); foreach ($excluded_columns as $value2) { echo "Excluded Column: <b>$value2</b><br>"; } foreach ($columnArr as $value) { if($value != "$value2") { $label = str_replace("_"," ","$value"); $label = ucwords("$label"); //echo "<b>$label</b>: "; echo "$_SESSION[$value]";?><br><?php echo "<b>$label</b>: "; echo "${$value}";?><br><?php } } ?> PROBLEM: Columns from the excluded list still get displayed. Edited November 19, 2018 by phpsanehello! in my header.php file i have the following line of code: Code: [Select] <link rel="stylesheet" href="<?php echo $pageCSS; ?>"> in the document proper, i have the following at the top of the page: Code: [Select] <?php $pageCSS="_css/compare.css"; ?> this works as expected and it's clean and neat. what i want to know is how i can adapt this to pass MULTIPLE JavaScript files through it. would it be best to pass an array of files and then step through the array? would be nice to be able to pass a simple comma-delimited list. any help would be appreciated. WR! Good day.
I have just written my first php phpexcell file importing into mysql without errors. now my next step is to try and read multiple excell files in a directory " files are same format" and import into mysql.
Heres my code so far.
<?php $db_host = "localhost";$db_user = "root";$db_pass = "";$db_name ="kk";$db_table = "test"; require '/Classes/PHPExcel.php'; require_once '/Classes/PHPExcel/IOFactory.php'; $objPHPExcel = PHPExcel_IOFactory::load('Amersfoort_WR.xlsx'); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $worksheetTitle = $worksheet->getTitle(); $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $nrColumns = ord($highestColumn) - 64; echo "File ".$worksheetTitle." has "; echo $nrColumns . ' columns'; echo ' y ' . $highestRow . ' rows.'; echo "$cellValue"; $link = mysql_connect($db_host,$db_user,$db_pass); if(!$link) die ('Could not connect to database: '.mysql_error()); mysql_select_db($db_name,$link); for ($row = 2; $row <= $highestRow; ++ $row) { $val=array(); for ($col = 0; $col < $highestColumnIndex; ++ $col) { $cell = $worksheet->getCellByColumnAndRow($col, $row); $val[] = $cell->getValue(); } $sql = "insert into test (F1, F2, F3, F4) values('".$val['0']."', '".$val['1']."', '".$val['2']."','".$val['3']."')"; mysql_query($sql); } } mysql_close($link); ?> I have this code and its downloading file nicely. But I want to show a progress bar while downloading file from external server. My existing code shows progress bar but its not effective (ex. if i try to download two media file, one video and another audio, and video size is larger than audio size the audio finishes first and the progress bar shows 100% also suddenly it drops to 50% as the video is still downloading ). I mean it actually shows two progress and I need one. If I could get average percentage value of two progress that would be better. Any suggestion regarding this will be greatly appreciated. <?php set_time_limit ( 0 ); function define_progress_callback($i) { global $conn; curl_setopt($conn[$i], CURLOPT_PROGRESSFUNCTION, function ($resource,$download_size, $downloaded, $upload_size, $uploaded) { if($download_size > 0) $progress = round($downloaded / $download_size * 100); echo '<script language="javascript">$(".loader").loader("setProgress", '.$progress.');</script>'; echo str_pad("",1024," "); flush(); usleep(20000); }); } $urls = array("http://example.com/file.mp3", "http:/example.com/file.mp4"); $save_to='./tmp/'; $conn = array(); $fp = array(); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $g = $save_to . basename($url); $conn[$i]=curl_init($url); $fp[$i]=fopen ($g, "wb"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // No certificate curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt ($conn[$i], CURLOPT_FILE, $fp[$i]); curl_setopt ($conn[$i], CURLOPT_HEADER ,0); curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,60); curl_setopt ($conn[$i], CURLOPT_MAXCONNECTS, 10); curl_setopt($conn[$i], CURLOPT_NOPROGRESS, false); define_progress_callback($i); curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); fclose($fp[$i]); } curl_multi_close($mh); ?> Edited by requinix, 18 January 2015 - 08:16 AM. no code tags meant auto-embedding of mp3 Hi I want to read multiple .txt files and then if an action requires select one. Quote <? // /home/person-mike.txt // /home/person-sarah.txt // /home/person-paul.txt while ($row = sqlite_fetch_array($result)) { $name = $row['name']; $filename = "/home/person-$name.txt"; $handle = fopen($filename, "r"); $sendrequest = fread($handle, filesize($filename)); fclose($handle); } ?> <? if ( $client == "sarah" ) { echo "$sendrequest[sarah]"; ?> How do I do the last bit to have a variable like $sendrequest[sarah] I am trying to convert 6 files into a single 1 php file. I have attached the original files. I need help because I don't know where I am going wrong. this what I have done so far : <?php session_start(); if ($_SESSION['ON'] =="FALSE" || $_SESSION['ON']==null) { header( 'Location: index.php?error=invalid-login' ); session_unset(); session_destroy(); exit(); } ?> <html><head><meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>LOGIN WEB SESSION</title> <link rel="stylesheet" type="text/css" href="loginsession.css" /> </head> <body> <?php // If the step is one, show the correct form // if ($step == 0) { echo '<form action="index.php?step=2" method="post"> <table> <tr><td width="100">Username:</td><td width="200"><input type="text" name="username"></td></tr> <tr><td width="100">Password:</td><td width="200"><input type="password" name="password"></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Login"></td></tr> </table> </form>'; } else if ($step == 1) { // Create the step 2 section of the page // function clean($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $user = clean($_POST['username']); $pass = clean($_POST['password']); if ($user == "webdeveloper" && $pass == "master") { session_start(); $_SESSION['username'] = $user; $_SESSION['password'] = $pass; $_SESSION['ON']="TRUE"; $lifetime=600; setcookie(session_name(),session_id(),time()+$lifetime); header( 'Location: index.php?step=2' ) ; exit(); } else { header( 'Location: index.php' ); session_destroy(); exit(); } } else if ($step == 2) <div>LOGIN WELCOME</div> <div> HERE IS YOUR USER DATA:<br /> <label class="data">username:'; <?php echo $_SESSION['username'] ?> <br> password: <?php echo $_SESSION['password'] ?> <br></label> HERE IS YOUR SESSION DATA:<br /> <label class="data"> <?php echo (session_name().": ".session_id()) ?><br> <?php echo ("SESSION DATA: ".session_encode() )?> </label> </div>index.php?step=3">Logoff</a></div> } else if ($step == 3) { // Create the step 4 section of the page // header( 'Location: index.php' ); session_start(); session_unset(); session_destroy(); exit(); } ?> </body> </html> Hi guys i am kinda stuck at a part where i want a download button to prompt out two download windows in a click. Currently i am able to prompt out one download window only. I have tried putting another header line of Content Disposition but it doesn't work..i will appreciate if you guys can help me out, thanks! The desired scenario will be WinSCP.exe download prompt will appear first, follow by auditgroup.bat $file1 = "WinSCP.exe"; $file = "auditgroup.bat"; //Set headers header("Cache-Control: private"); header("Expires: 0"); header("Pragma: cache"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename=$file"); header("Content-Type: application/octet-stream"); header("Content-Transfer-Encoding: ASCII"); //Read the file from disk readfile($file); Hey I have this code which works fine, it echos the file names from a directory into a dropdown box how can I change it to include more then one directory <?php $dirname = "../images/staff"; $dir = opendir($dirname); echo '<select name="file2">'; echo '<option value="">none</option>'; while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..")) { echo "<option value=".$file.">$file</option>"; } } echo '</select>'; ?> I tried this but it didnt work any help <?php $dirname = "../images/staff"; $dirname .= "../images/boarddirectors"; $dir = opendir($dirname); echo '<select name="file2">'; echo '<option value="">none</option>'; while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..")) { echo "<option value=".$file.">$file</option>"; } } echo '</select>'; ?> |