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

jQuery hide() flicker
Cascading dropdown with jQuery
Regex to match alphanumeric characters, underscore, periods and dash, allowing dot and dash only in the middle
Setting Facebook PHP SDK access_token with setAccessToken()
How do I modify the path used by exec in php
Broken link check while initiating cron-multi
How to format `23/05/2012` into insertable value in DATETIME column?
will users see post on their wall,if a post is made on app page
Wordpress Loop passing variables
PHP Imagick - setTextEncoding() function doesn't work
Upload PHP Code not uploading image
Why create own request object? [closed]
array declration methods in php [closed]
File extension filter when choosing file to upload
Secure file storage in a server
MySQL: Avoid selecting columns with the same userid

Categories

HOME
memory
class
generics
gaming
verification
yaml
couchdb
hid
dry
website
vsts-build
semantic-web
wine
log4j2
hystrix
slide
cname
bootstrap-switch
sslhandshakeexception
cuba-platform
texas-instruments
rest-assured
l20n
playframework-2.0
maven-plugin
jaspersoft-studio
adminlte
spring-shell
unity-container
dashdb
uislider
ini
ipa
uri
android-cardview
uilocalnotification
bonita
sfml
sparkle
progid
mapnik
overwrite
nest
directfb
twilio-php
spring-restcontroller
flowchart
right-click
plane
code-push
nuclio
spongycastle
hibernate-ogm
solr-query-syntax
punctuation
stateless-session-bean
predicates
dynamics-crm-4
business-rules
pbx
gawk
boost-compute
streamwriter
seccomp
deferred-rendering
sharepoint-apps
urbit
preferenceactivity
okta-api
flask-security
phpquery
darwin
componentart
ocmockito
kotlin-android-extensions
sablecc
camus
signed
cakephp-2.2
mfmessagecomposeview
hyperloglog
profiles
typesafe-stack
strdup
spring-security-acl
iirf
sql-view
sunstudio
flv
significant-digits
stretch
motodev-studio
dip
mongrel
explicit
icicles
tabbarcontroller
aspbutton
powergui
accumulator
version-control-migration
isapi-redirect
remote-working

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