
bbmak
Members-
Posts
50 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
bbmak's Achievements

Member (2/5)
0
Reputation
-
How to split a search strings and put it into a prepare statement?
bbmak replied to bbmak's topic in PHP Coding Help
Awesome, thx u guys.- 6 replies
-
- search string
- split
-
(and 1 more)
Tagged with:
-
Where do you put opening curly braces when defining a method?
bbmak replied to NotionCommotion's topic in PHP Coding Help
I think it is personal perference... I used #2, and I like the { } vertical allign -
How to split a search strings and put it into a prepare statement?
bbmak replied to bbmak's topic in PHP Coding Help
Can you show an example of dynamic binding in PDO? I planned to move PDO in future, but I stayed with mysqli for now. I have to rewrite my functions and classes in pdo. I may switch to hybrid mode though.- 6 replies
-
- search string
- split
-
(and 1 more)
Tagged with:
-
Hi, How do you split a search string by space and put it into a prepare query? $strings = $_POST['strings']; $string_array = explode(" ", $strings); $search = $mysqli->prepare(" SELECT * FROM core_table where item_name in ( ? ) "); $search->bind_param("s", $string_array); ...
- 6 replies
-
- search string
- split
-
(and 1 more)
Tagged with:
-
Thanks This seems even better than putting a case when statement in the query for my case.
-
Instead of writing 2 separated query, are there anyway to put a case statement when in the where clause of the query? $category_id will be null if on front page and not null on category pages. So, I want to put a statement on the highlighted part. However, it seems not working. Can someone help with my syntax. case when $category_id is Null THEN "" when $category_id is not Null THEN ci.cat_id = ? function next24($category_id, $lastItemID) { if(!empty($lastItemID)) { if($next24item = $this->mysqli->prepare(" SELECT ci.id as item_id, ci.cat_id as cat_id, ci.item_name, ci.item_description, ci.item_note, ci.item_price, ci.item_discount, ci.item_url, ci.date_created, ci.date_updated, ci.date_expired, cii.item_id as cii_item_id, cii.item_image_filename, cm.merchant_name, cm.merchant_url, cm.merchant_description, cm.merchant_logo_thumb From core_item ci LEFT JOIN core_merchant cm on ci.merchant_id = cm.id LEFT JOIN core_item_image cii on cii.item_id = ci.id WHERE ci.id < ? AND case when $category_id is Null THEN "" when $category_id is not Null THEN ci.cat_id = ? ORDER BY ci.id DESC LIMIT 24 ")) { $next24item->bind_param("ii", $lastItemID,$category_id); $next24item->execute(); $next24results = $next24item->get_result(); return $next24results->fetch_all(MYSQLI_BOTH); } } else { break; } } Thanks
-
thanks, got it echo '<li><a href="#" onclick="openLink(\'item.php?merchant_id=' . $cat_id . '\')">' . $cat_name . '</a></li>';
-
Hi Having problem with putting ' in to my link . this is what i want on the link <li><a href="#" onclick="openLink('item.php?merchant_id=x')>Category 1</a></li> this is my mess echo '<li><a href="#" onclick="openLink('''; ?>item.php?merchant_id=<? echo $cat_id . ''')">' . $cat_name . '</a></li>'; & try this echo '<li><a href="#" onclick="openLink('''item.php?merchant_id=' . $cat_id . ''')">' . $cat_name . '</a></li>';
-
Hi, 1. I got my code working, but not sure this is the proper way to return an array from a prepare statement. 2. when I use bind_result($var), are there anyway to include all columns without typing them all? if($next24item = $this->mysqli->prepare("SELECT ci.id as item_id, ci.item_name, ci.item_description, ci.item_note, ci.item_price, ci.item_discount, ci.item_url, ci.date_created, ci.date_updated, ci.date_expired, cii.item_id as cii_item_id, cii.item_image_filename, cm.merchant_name, cm.merchant_url, cm.merchant_description, cm.merchant_logo_thumb From core_item ci LEFT JOIN core_merchant cm on ci.merchant_id = cm.id LEFT JOIN core_item_image cii on cii.item_id = ci.id WHERE ci.id < ? ORDER BY ci.id DESC LIMIT 24")) { $next24item->bind_param("i", $lastItemID); $next24item->execute(); $next24results = $next24item->get_result(); return $next24results->fetch_all(MYSQLI_BOTH); }
-
PHP Fatal error: Call to a member function prepare() on null
bbmak replied to bbmak's topic in PHP Coding Help
Thank you guru. -
PHP Fatal error: Call to a member function prepare() on null
bbmak replied to bbmak's topic in PHP Coding Help
I go back and check my connection. The file include the wrong path for the connection folder. I fixed that, and now I got this. PHP Fatal error: Call to undefined method mysqli_stmt::fetch_array() -
PHP Fatal error: Call to a member function prepare() on null
bbmak replied to bbmak's topic in PHP Coding Help
ummm.... I have other functions in the class using $this->mysqli-query(), and they work fine. Somehow the prepare() is not working. I am new to prepare(), and not sure my syntax is correct or not. -
PHP Fatal error: Call to a member function prepare() on null
bbmak posted a topic in PHP Coding Help
Hi Trying to implement with the prepare statement, and it gives me this error. "PHP Fatal error: Call to a member function prepare() on null." Anybody knows what is wrong? function listMerchant() { $merchant = array(); $merchantList = $this->mysqli->prepare("SELECT * FROM core_merchant"); $merchantList->execute(); while($merchantRows = $merchantList->fetch_array()) { $merchant[] = $merchantRows; } $merchantList->close(); return $merchant; } -
Call $variable at the top of script, before declaring them?
bbmak replied to bbmak's topic in PHP Coding Help
I am writing php as a hobby, not professional, always curious on programming langs How do you suggest the templates? If I have include $pages in the templates?