• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nooby Codeigniter user! MYSQL Query

#1
[eluser]mr daniel[/eluser]
Hullo guys Smile


So I've just been playing around with codeigniter and mysql.
I need to execute the mysql query:
Code:
SELECT COUNT(id) FROM urls;
and want to show the result on the main page of my website.



So I've been trying something like
Code:
<php echo $idcount; ?&gt;
on the website and in my controller, "g.php" I've been using
Code:
$this->view_data['idcount'] = mysql_query(SELECT COUNT(id) FROM urls;);



Is there an easy way to do this?
I've been struggling so far Sad
Any help would be appreciated <3


EDIT: mistyped code

#2
[eluser]jmadsen[/eluser]
There sure is.

Here's the manual where they talk about how to use databases.

http://ellislab.com/codeigniter/user-gui...index.html

#3
[eluser]mr daniel[/eluser]
[quote author="jmadsen" date="1341823224"]There sure is.

Here's the manual where they talk about how to use databases.

http://ellislab.com/codeigniter/user-gui...index.html[/quote]

Thanks very much!

Trying it now but still struggling. Will keep going!

#4
[eluser]mr daniel[/eluser]
All fixed and done Big Grin

Was as simple as using
Code:
&lt;?php echo $this->db->count_all('urls'); ?&gt;


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.