Tags » PHP/MySQL

foreach2

<?php 
try {
	$conn = new PDO('mysql:host=localhost;dbname=opencart', 'root', '');
	$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
	echo 'ERROR: ' . $e->getMessage();
}

$sql = 'SELECT * FROM oc_product_description LEFT JOIN oc_product ON oc_product_description.product_id=oc_product.product_id';
$query = $conn->prepare($sql);
//$sql = 'SELECT product_id, oc_product.image, oc_manufacturer.name as manufacturer FROM oc_product, oc_manufacturer WHERE oc_product.manufacturer_id = oc_manufacturer.manufacturer_id';
$query->execute();
$products = $query->fetchAll(PDO::FETCH_ASSOC);

// echo '<pre>';
// print_r($products);
// echo '</pre>';

foreach ($products as $product) {
	if($product['quantity'] == 10000){
		$product_array[] = $product['product_id'];
	//echo $product['name'] .'<br>';
	}

}

//echo implode(', ', $product_array);

if (!empty($product_array)) {

?>


	var_total = 
	var_ids = 



<?php
}
?> 20 more words
PHP/MYSQL

foreach group by field

<?php

$sql = 'SELECT * FROM oc_product_description LEFT JOIN oc_product ON oc_product_description.product_id=oc_product.product_id';
$query = $conn->prepare($sql);
$query->execute();
$products = $query->fetchAll(PDO::FETCH_ASSOC);

$quantity_group = [];

foreach ($products as $product) {

	//Δημιουργούμε τον πίνακα $quantity_group και δημιουργούμε
	// κλειδιά ανάλογα με την ποσότητα (η κάθε ποσότητα είναι
	// ξεχωριστό κλειδί) τα οποία είναι πίνακες που περιέχουν
	// προϊόντα
	$quantity_group[$product['quantity']][]=$product;

}
// Ταξινομούμε τα κλειδιά του πίνακα με φθίνουσα σειρά. 70 more words
PHP/MYSQL

Complete CMS tutorial with Admin Panel & PHP-MYSQL website in hindi-urdu

Complete website of CMS in PHP-MYSQL Tutorial in hindi-urdu Lecture-01

——————————————————————————————————–

Complete website of CMS in PHP-MYSQL Tutorial in hindi-urdu Lecture-02

———————————————————————————————————-

Complete website of CMS in PHP-MYSQL Tutorial in hindi-urdu Lecture-03… 88 more words

PHP&amp;MYSQL

Regular Expressions In PHP

+ Ký hiệu “^” và “$”: bắt đầu và kết thúc 1 string

Example 1:

&lt;?php
$pattern = '/^hello/';  // biểu thức chính quy cho một string bắt đầu bởi chuỗi "hello"
$string = 'hello world';
if(preg_match($pattern, $string)) {
   echo 'Yes';
} else {
   echo 'No';
}
// result: Yes 723 more words
Regular Expression