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

Get the selected radio values into next page using php for online examiation
Wordpress uploads folder permission issue
How to fetch each array?
DIV created by PHP ECHO wont style properly from external CSS
Route class doesn't working properly
get_the_category_by_id() for custom taxonomy
ClassNotFoundException in AppKernel.php line 20 - Symblog part 5
I'm tyring to turn VBB3 Plugin to VBB4
Slash command response not parse correctly
How to merge array of objects keeping data in PHP
Rewrite every url to go to directory
how to change mysql database code into postgresql code using core php?
How to apply Doctrine metadata change in Symfony
Force size for post_thumbnail
Sort Data in php array according to some key
Symfony/Validator: Property validation in Callback

Categories

HOME
ionic2
macos-sierra
focus
applescript
redmine
concurrency
swi-prolog
activex
histogram
consul
amp
phpmqtt
anchor
sharepoint-online
solution
fasm
lapack
locationmanager
pm2
grocery-crud
powermock
google-cloud-logging
user-defined-types
google-sites
salt-cloud
clr
libgit2
error-logging
spring-ldap
neo4j.rb
coreldraw
liferay-6.2
animated-gif
web-push
data-collection
tracing
uri
react-bootstrap-table
php-5.3
sendmessage
laravel-4.2
quick-nimble
series
actframework
amazon-kms
buildforge
busboy
spinner
djcelery
xll
gitolite
stat
imgur
utf
secure-coding
cloudera-sentry
fluid-mac-app-engine
moinmoin
bit-shift
gcal
directwrite
icecast
xcglogger
sony-future-lab-n
amazon-elastic-beanstalk
subforms
nivo-slider
stateless-session-bean
email-forwarding
zend-server
emf-compare
front-camera
openerp-6
nsrunloop
adp
distributed-cache
mixins
unidata
sablecc
htmltidy
full-text-indexing
forio-contour
wso2bam
ivalueconverter
flipboard
profiles
pbkdf2
progress-db
apache-shindig
unrealscript
days
dojo-1.9
xalan
arrow
cakeyframeanimation
liveconnect
dynamic-c
grails-validation
active-record-query
rational-unified-process

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App