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

What should an HTML 5 form submit when no value is set [duplicate]
How to present enum table property in Laravel Model
Send request “post” with hidden field and wordpress
PHP and MySQL pagination issue
php - performance of continue state
ZF2 Model getters and setters mismatching form element names
Selecting and matching data from 3 tables
How to get the request data in codeigniter
Format dynamic ul list generated by php
python doesn't write if call from php
while loop and session fix code
WP All Imports Custom Function
Login with Nativescript and Prestashop
Php Socket Programming Connection times out escpos-php
propagate drop down with basename of images in current directory php
Converting an Object to an Array with PHP

Categories

HOME
qt
yaml
eclipse-plugin
postgresql-9.4
writefile
windows-10
adobe
slider
lvm
kurento
colors
clish
angular4
jquery-file-upload
complexity-theory
asciimath
cocos2d-android
pickle
office-ui-fabric
gmp
pfobject
neo4j.rb
dragula
tracing
beego
tortoisehg
miniprofiler
matlab-app-designer
vcenter
snap-framework
caesar-cipher
ms-media-foundation
payeezy
cmis
grails-2.5
runtimeexception
djcelery
installanywhere
forms-authentication
variable-variables
strapi
microsoft-ui-automation
angular-datatables
word-cloud
music21
spongycastle
sony-future-lab-n
google-news
portability
glassfish-4.1
portal
cefpython
xcode8-beta4
bbc-micro
xcopy
voronoi
perceptron
decidable
ibm-was
mousehover
asp.net-web-api-helppages
green-threads
relational-model
mgwt
operands
juttle
image-rotation
producer
treeline
mfmessagecomposeview
csslint
.htpasswd
preorder
pre
principalcontext
strdup
codahale-metrics
microformats
dynamic-rdlc-generation
notin
ntlmv2
jquery-dialog
daap
android-dialog
kaazing
yuidoc
fork-join
css-friendly
servlet-container
bass
browser-based
twitter-feed

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App