Welcome Guest, Not a member yet? Register   Sign In
retrive data from database
#1

[eluser]abada[/eluser]
hello

i used tinymce editor and my question is how can read (html)data from database to show it

this is my insert fn model
Code:
function addNews()
    {
            $fields = array(
                    
                    'news_title_ar'        => $_REQUEST['news_title_ar'],
                    'news_title_en'        => $_REQUEST['news_title_en'],
                    'news_desc_ar'        => htmlentities($_REQUEST['news_desc_ar']),
                    'news_desc_en'        => htmlentities($_REQUEST['news_desc_en']),
                    'news_image'        => $_REQUEST['Image'],
                    'active'        => $_REQUEST['active'],
                    'news_catID'        => $_REQUEST['news_catID'],
                    
                        );
        
        $this->db->insert('news',$fields);
        
        $topicid = $this->db->insert_id();
        $id = $topicid;
        return $id;
    }


and this my query fn

Code:
function getNewsData()
    {
        $query = $this->db->query("SELECT * FROM news  where news_id=12");
        $data = array();
        
        foreach($query->result() as $row) {
        
            $data[]=array('news_id' => $row->news_id,'news_desc_en' => $row->news_desc_en);
        }

        return $data;
    }


the data not showen as inserted formatted

thanks
#2

[eluser]bigtony[/eluser]
You could try using html_entity_decode when reading from database in order to reverse the action of htmlentities.

Something that concerns me about your code is using $_REQUEST. Values in here should not be trusted as malicious users can insert scripts or sql injections (same problem if directly using $_POST or $_GET). I strongly recommend you use the $this->input->post('fieldname') function that comes with codeigniter, and make sure you are also doing xss_clean (you can set it to run automatically). This will make your scripts much safer from hackers.
#3

[eluser]abada[/eluser]
thanks bigtony

but i really use bigtony html_entity_decode

echo html_entity_decode($data['condesc'][0]['news_desc_en']);

any other solution

and i have another problem if i use smile in tinymce it doesn`t appear when i read it feom database

thanks all
#4

[eluser]bigtony[/eluser]
[quote author="abada" date="1239406244"]thanks bigtony

but i really use bigtony html_entity_decode

echo html_entity_decode($data['condesc'][0]['news_desc_en']);

any other solution

and i have another problem if i use smile in tinymce it doesn`t appear when i read it feom database

thanks all[/quote]
I usually use active record to read & write to database, and when I used it with tinymce I did not need to use either htmlentities or html_entity_decode. Might be worth trying for you. Sorry, never used smilies but maybe active record might solve for this too!?




Theme © iAndrew 2016 - Forum software by © MyBB