Skip to content

Instantly share code, notes, and snippets.

View MahbbRah's full-sized avatar
🎯
Focusing

Mahbub Rahman MahbbRah

🎯
Focusing
  • Dinajpur, Bangladesh
View GitHub Profile
@MahbbRah
MahbbRah / js.md
Created August 25, 2017 13:59 — forked from nuhil/js.md
Javascript Handbook

Javascript Handbook

A hand crafted markdown document contains all major Javascript topics covered, taken from different sources. Brush Up your JS memory.

Comments


Single line comments start with //. For multi-line commands, you use /* ... */

// This is a single line comment
@MahbbRah
MahbbRah / multiple-insert.php
Created July 26, 2016 02:32
multiple insert in single submission
<?php
ob_start();
include('../db_config.php');
$db = database::getInstance();
$sql = "SELECT * FROM computer";
$result = $db->dbc->query($sql);
$count = $result->rowCount();
?>
@MahbbRah
MahbbRah / query.php
Created April 26, 2016 16:02
multiple value update in single query
<?php
ob_start();
include('../db_config.php');
$db = database::getInstance();
$sql = "SELECT * FROM computer";
$result = $db->dbc->query($sql);
$count = $result->rowCount();
?>
@MahbbRah
MahbbRah / addition.php
Created April 26, 2016 15:59
As you can see this is a working query. and now I want to add first and second field (int) value on 3rd field like $f_name + $m_name = value; with loop. how could i do that?
<?php
if(isset($_POST['Submit'])){
for($i=0;$i<$count;$i++){
$name = $_POST['name'];
$f_name = $_POST['lastname'];
$m_name = $_POST['email'];
// This is a query for uploading multiple values in single query.
$sql1="UPDATE computer SET s_name='$name[$i]', f_name='$f_name[$i]', m_name='$m_name[$i]' WHERE roll='$id[$i]'";
@MahbbRah
MahbbRah / query.php
Created April 22, 2016 05:29
How to convert this in php query ?
<?php
SET @sql = NULL;
SELECT
GROUP_CONCAT(DISTINCT
CONCAT(
'max(CASE WHEN ca.date = ''',
date_format(date, '%Y-%m-%d'),
''' THEN coalesce(p.status, ''P'') END) AS `',
date_format(date, '%Y-%m-%d'), '`'
)
<?php foreach ($result as $row) {
$value1 = strpos($row['c_main_title'], $searchValue) !== FALSE;
$value2 = strpos($row['c_main_body'], $searchValue) !== FALSE;
$value3 = strpos($row['cmt_dept_title'], $searchValue) !== FALSE;
$value4 = strpos($row['cmt_dept_body'], $searchValue) !== FALSE;
$value5 = strpos($row['aidt_dept_title'], $searchValue) !== FALSE;
$value6 = strpos($row['aidt_dept_body'], $searchValue) !== FALSE;
$value7 = strpos($row['food_dept_title'], $searchValue) !== FALSE;
$value8 = strpos($row['food_dept_body'], $searchValue) !== FALSE;
$value9 = strpos($row['rac_dept_title'], $searchValue) !== FALSE;
@MahbbRah
MahbbRah / search-result.php
Last active April 17, 2016 09:07
Actually, I'm trying to to create a search form for a personal website that have single search form and multiple DB fields. if data match with input value then that field or similar all fields will echo .
<?php
if(isset($_GET['submit_value']) && !empty($_GET['search_input']))
{
include("db_config.php");
$db = database::getInstance();
$searchValue = $_GET['search_input'];
$sql = "SELECT * FROM `sitedata` WHERE c_main_title LIKE '%$searchValue%' OR c_main_body LIKE '%$searchValue%' OR cmt_dept_title LIKE '%$searchValue%' OR cmt_dept_body LIKE '%$searchValue%'
OR aidt_dept_title LIKE '%$searchValue%' OR aidt_dept_body LIKE '%$searchValue%' OR food_dept_title LIKE '%$searchValue%' OR food_dept_body LIKE '%$searchValue%' OR rac_dept_title LIKE '%$searchValue%'