php


Comparing first 4 characters from table and fetching data from database in codeigniter


I have two different tables as testimonial and pagetitles. While fetching the Pagetitles from database i need to compare first 4 characters if the both matches then i should get the data.
function getpagetitle($id)
{
$this->db->select('P.*,T.testimonial_name');
$this->db->from('pagetitle AS P');
$this->db->join('testimonials AS T','SUBSTR(T.testimonial_name, 4) = SUBSTR(P.page_title, 4)','INNER');
$this->db->where(array('P.page_title'=>$id));
$q=$this->db->get();
//var_dump($this->db->last_query());
//print_r($q->num_rows());
if($q->num_rows()>0)
{
$output = $q->result();
return $output[0];
}
else
{
return false;
}
}
Database tables
testimonials:
testimonial_id | testimonial_name |client_name
1 testimonial abc
2 testimonial def
Pagetitle
pagetitle_id | pagetitle
1 testimonial
2 career
i think you have to use if then statement in mysql ,
so if we want to change your query , it must be something like this :
select P.*,T.testimonial_name from pagetitle AS P , testimonials as T (
select IF 'SUBSTR(T.testimonial_name, 4) = SUBSTR(P.page_title, 4)'
where P.page_title>5
)
i dont test it , but i think it must be true

Related Links

angularjs slim 404 not found for GET request
Php Mysqli questions and handler library/class
XAMPP (WAMP) server - disable accessing files outside of root directory
Tabs - Content shown after clicking one of the tab (Bootstrap)
SilverStripe: Forbidden Permission Error
Php/sqli executed by referencing the link in a send email function?
Creating an invoice line using Odoo (OpenERP) WebService API for PHP
Where do I point my Cron job path?
str_replace in post_content with increment value using php
mysql Duplicate error handling
How can i use the Twig template engine without modifying the php.ini?
Linking Not working
pass vars from iframe to wordpress site
Make a directory with HUNGARIAN characters PHP
How to use xquery to find node and addChild to it?
Cassandra remote database not retriving data with PHP while retriving with nodejs

Categories

HOME
entity-framework
flask
yii
exchange-server
haproxy
risk-management
semantic-web
malware
cryptography
google-webmaster-tools
ipv6
azure-mobile-services
reportviewer
siesta
driver
locationmanager
grocery-crud
texas-instruments
psql
spring-shell
amazon-mws
perfino
strophe.js
webviewclient
multi-dimensional-scaling
sales
javax.persistence
mdns
substance
dotcms
android-collapsingtoolbar
apptentive
xerces-c
jfxtras
formsauthenticationticket
django-crispy-forms
imgur
slideshow
ejml
1wire
permission-denied
cloudwatch
uiautomatorviewer
dex
ltrace
sidewaffle
nrf51
jpda
django-testing
vaadin4spring
deeplink
cryptojs
decidable
directx-9
hmisc
gql
google-gdk
algebraixlib
artisan
physicsjs
r.java-file
subview
jcheckbox
juttle
string.format
rubber
jquery-mobile-flipswitch
quantify
communicate
coding-efficiency
windows-messages
csslint
code-complexity
stripe.net
preorder
wso2bam
map
ggts
non-ascii-characters
google-code-prettify
user-forums
stretch
kobold2d
ognl
multiple-users
uninstaller
pinax
iphone-sdk-4.3
ppc
wmd-editor
efs
icon-language

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile