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

WordPress: Ajax response overwrites the whole page
PHP file temporarily unavailable
Simplified anarchy “if statement”
swift 3: Get rtf formatted text from MySQL
Doctrine queryBuilder: SQL Injection risk in addOrderBy() method?
Data table error
Checking user privileges before executing functions
SilverStripe sort page list by custom order
Where is this stylesheet being loaded from?
htaccess rewrite URL php parameters
Ubuntu - Prevent Linux/Apache users from listing anything but their home directory with PHP
Solidres appearance
when dispatcher parameter destroy using phalcon
Android :How to load but not open URL
Understanding how salt is generated/used in bcrypt password_hash
i want to compare the string and show to characters which match in both strings in php

Categories

HOME
google-chrome
elasticsearch
extjs
android-espresso
shinyapps
dotnetnuke
barcode-scanner
paypal-ipn
swi-prolog
embedded-resource
visual-studio-2010
tcp
mathematical-optimization
flurry
swarm
spring-security-oauth2
xades4j
smooks
grocery-crud
live-streaming
playframework-2.0
significance
fido-u2f
fluent-migrator
morris.js
crud
ruby-daemons
python-imageio
ccavenue
sendmessage
tsung
knights-tour
osx-lion
telephonymanager
django-smart-selects
hdiv
secure-coding
dagger
sharpdx
maven-jaxb2-plugin
android-sharing
gnome-terminal
.when
front-camera
cognos-tm1
fitbit
qtextedit
pjax
libharu
android-syncadapter
wicked-pdf
jemdoc
textblock
management-studio-express
wif4.5
linuxbrew
modern.ie
mgwt
sablecc
r.java-file
findersync
nanomsg
comctl32
vs-unit-testing-framework
dmake
windows-rt
xhprof
lmax
nidaqmx
libgcc
accessory
windows-messages
.htpasswd
flipboard
jms-serializer
cloo
eclim
colon
mute
hints
xs
jquery-lazyload
blobstorage
office-app
ip-geolocation
fitch-proofs
database-deadlocks
bll
ccl
3-tier
pinax
principles
powergui

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