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

html files does not load containing python files when button is clicked
MariaDB has both `authentication_string` and `Password` field in the `mysql.user` table
save() method only writing last record in my form
Facing error in mysqli with php
Function name must be string on Calculation in PHP function
Accessing a php variable value in html <p> </p> tag I
Cannot POST /demo.php
Remove all href 'wrapper' except href contains specific value: PHP
Deploying codeigniter on heroku works fine on localhost but path issues on heroku
What is VB.net Nothing equivalent in PHP?
php undefined index coming on uploading file with ['name']
HTML Form Logic Issue ( 2 Forms ) form-1 is not remembering data
Alpha Numeric values xcannot be retrieved in PHP
“Leverage browser caching” error
PHP accessing external server within script slow in multiples of 5 seconds
How I can find matching data row in Mysql table?

Categories

HOME
python-2.7
android-studio
windows-8.1
vagrant
scroll
devexpress
kivy
loopbackjs
bing-search
gallery
moodle-api
stored-procedures
phpmqtt
joomla3.2
telegraf
wine
yahoo
spring-security-oauth2
scrape
orc
django-rq
orange-api
temperature
fosuserbundle
cpu-usage
spring-shell
android-custom-view
opam
data-type-conversion
el
connection-refused
cellular-network
offline-caching
react-bootstrap-table
boolean-logic
substance
audit
winsock
tightvnc
delayed-job
devtools
love2d
django-crispy-forms
ms-dos
cartopy
strapi
llvm-ir
iscroll
oauth2
stat
flipkart
permission-denied
libreoffice-writer
sony-future-lab-n
lightning-workbench
exc-bad-access
deedle
portability
ptvs
cefpython
multi-touch
jpda
p6spy
carmen
seccomp
oci
preferenceactivity
perceptron
smart-tv
variable-length-array
dsa
scala-swing
tkx
mojo
microsoft-expression-web
lync-2010
strcmp
discovery
insertonsubmit
mp4parser
jacob
acceptance-testing
chartfx
mongo-jackson-mapper
itunes-sdk
stretch
sfinae
telerik-ajax
kobold2d
fbml
expression-web
asio
winsxs
kernel32
digiflow
outlook-2007-addin
.net-client-profile
inversion
stretchblt
isapi-redirect
community-server

Resources

Encrypt Message