Welcome Guest, Not a member yet? Register   Sign In
How to sent the result of SQL query to a variable(not array)?
#1

[eluser]Sinclair[/eluser]
Hi,

I'am with some problems to get the "title" of an article from database and send it to a normal variable(not array).

My model:
Code:
function getTituloAnuncio($pid_anuncio) {
        $query = $this->db->query("select a.n_anuncio from atw_anuncios a where
        a.id_anuncio = '".$pid_anuncio."'");
        return $query->result();
    }

My Controller code:
Code:
$title = $this->acomp_model->getTituloAnuncio($pid_anuncio = $this->uri->segment(3)); # Aqui

My view:
Code:
<html>
<head>
<title>
    <?php echo $title; ?>
</title>
</head>

The final result is that I see the word "Array" printed instead the title. How can I print the variable when I know that the query only returns one line?


Best Regards,


Messages In This Thread
How to sent the result of SQL query to a variable(not array)? - by El Forum - 10-18-2009, 02:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB