Welcome Guest, Not a member yet? Register   Sign In
User System
#31

[eluser]majidmx[/eluser]
Glad to hear it worked eventually ...
To make your code more accurate, try to put all those configuration in the config.php file of the config folder and try to execute the DB queries from a Model, and get the results in the controller.

For the issue you mentioned, what's the problem ? I just can not figure it out what's the problem ?
Do you mean the line breaks ?
if YES, then take a look at typography class Here.
and if NO, please explain more Wink

Take care,
MajiD Fatemian
#32

[eluser]plasmagames[/eluser]
ok, heres what i mean.
I want to know how to get the text to format the way i want it.

So if i type:

Google

Here is an example of what i mean

and here what i want it to be like:

Google

Here is an example of what i mean

not like this:

GoogleHere is an example of what i mean
#33

[eluser]majidmx[/eluser]
did you tried the Typography Helper ? it is exactly what you need.
#34

[eluser]jcavard[/eluser]
@plasmagames
Come on Dude! The CI Community sure is one great, but for f* sake, would you at least read some tutorials, search twikis, browse forums before posting every GD errors you get with code people gave you in the first place? Try to understand what you're doing, instead of begging for code. damn, that's sad.
#35

[eluser]plasmagames[/eluser]
ok so i read the page how would i sue it in my view file

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;

&lt;link href="http://plasmasteelgames.net/code/assets/psgv.css" rel="stylesheet" type="text/css"&gt;

&lt;/head&gt;
&lt;body&gt;
<center>
<h1>&lt;?=$heading?&gt;</h1>
<h4>&lt;?=$slogan?&gt;</h4>
</center>
<hr />


&lt;?php foreach($query as $row): ?&gt;
<h3>&lt;?=$row->title?&gt;</h3>
<h5>&lt;?=$row->author?&gt;</h5>
<hr />
<p>&lt;?=$row->body?&gt;</p>
<hr />

&lt;?php endforeach; ?&gt;


&lt;/body&gt;
&lt;/html&gt;
#36

[eluser]plasmagames[/eluser]
would it be like this?

Code:
$string = auto_typography($row);
#37

[eluser]plasmagames[/eluser]
and to you comment jcavard.

I don't learn buy reading tutoials and wiki's I learn by video tutorials and coding something and if theres errors get other to help me fix them. Since I am completely new to CodeIgniter in this case. we all learn in different ways, so shut the hell up. Please
#38

[eluser]jcavard[/eluser]
You're not proving me wrong dude! Just look in the User Guide, and you will see the auto_typography() syntax!
That's what I meant.

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

Code:
// you usually put this in your controller

// load the helper, unless it's being autoloaded
$this->load->helper('typography');

then replace your foreach
Code:
&lt;?php foreach($query as $row): ?&gt;
<h3>&lt;?= $row->title; ?&gt;</h3>
<h5>&lt;?= $row->author; ?&gt;</h5>
<hr />
<p>&lt;?= auto_typography( $row->body); ?&gt;</p>
<hr />
&lt;?php endforeach; ?&gt;
#39

[eluser]plasmagames[/eluser]
ok, i have gotten to the comments part where it displays them. So far the script will submit the comments but won't display them.


Heres what the browser gives me
Quote:Fatal error: Call to a member function num_rows() on a non-object in /home/pmgames/public_html/code/system/application/views/newscomment.php on line 16

Here's the Code for the comment view file
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;

&lt;link href="http://plasmasteelgames.net/code/assets/psgv.css" rel="stylesheet" type="text/css"&gt;

&lt;/head&gt;
&lt;body&gt;
<center>
<h1>&lt;?=$heading?&gt;</h1>
</center>
<hr />

    &lt;?php if ($query->num_rows() > 0): ?&gt;
    &lt;?php foreach($query as $row): ?&gt;
    <h5>&lt;?= $row->author; ?&gt;</h5>
    <hr />
    <p>&lt;?= auto_typography( $row->body); ?&gt;</p>
    <br />
    <hr />
    &lt;?php endforeach; ?&gt;
    &lt;?php endif; ?&gt;


<hr />
<p>&lt;?=anchor('news/comments/'.$row->id, 'Comment');?&gt;</p>

&lt;?=form_open('news/comment_insert');?&gt;

&lt;?=form_hidden('entry_id', $this->uri->segment(3));?&gt;

<p><b>Comment</b></p>
<p>&lt;textarea name="body" rows"10" cols="50" rows="10"&gt;&lt;/textarea></p>
<p>Author:</p><p>&lt;input type="text" /&gt;&lt;/p>
<p>&lt;input type="submit" value="Add Comment" /&gt;&lt;/p>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;


and heres the controller
Code:
&lt;?php

class News extends Controller {

    function News()
    {
        parent::Controller();
            */the Database Connection Info\*

            $this->load->database($config);
            
            $this->load->scaffolding('news');
            
            $this->load->helper('typography');
            $this->load->helper('form');
            $this->load->helper('url');
    }

    function index()
    {
        $data['title'] = "Plasma Steel Games | Bring Out Your Inner Gamer!";
        $data['heading'] = "Plasma Steel Games";
        $data['slogan'] = "Bring Out Your Inner Gamer!";
        $data['query'] = $this->db->query('SELECT * FROM news')->result();
                
        $this->load->view('index.php', $data);
    }
    
    function comments()
    {
        $data['title'] = "Plasma Steel Games | News Comments";
        $data['heading'] = "Comment Title";
        $this->db->where('entry_id', $this->uri->segment(3));
        $data['query'] = $this->db->query('SELECT * FROM comments')->result();
                
        $this->load->view('newscomment.php', $data);
    }
    
    function comment_insert()
    {
        $data['query'] = $this->db->query('SELECT * FROM comments', $_POST)->result();
        redirect('news/comments/'.$_POST['entry_id']);
    }
}

?&gt;
#40

[eluser]majidmx[/eluser]
Please pay more attention to the user_guide.

As you can see here [http://ellislab.com/codeigniter/user-gui...sults.html] , you can use ->num_rows() on a query object not a query_result object.
here is the correct one :

Code:
$query = $this->db->query('SELECT * FROM my_table');

echo $query->num_rows();
and what you're doing is :
Code:
$query = $this->db->query('SELECT * FROM my_table')->result();

echo $query->num_rows();

Each class has it's own methods and properties.
When you face an error which seems to be so simple, there should be something wrong with your code, spend more time on tracing your code, though the error itself is self-explaining.




Theme © iAndrew 2016 - Forum software by © MyBB