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?