• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CodeIgniter PHP Profile

troja

SD 2014
Joined
Jan 1, 2009
Messages
2,116
Reaction score
54
Hello,

Could someone please post a simple profile script?

With that I mean that the URL should be like “profile/NAME” or “profile/ID”.

It should select the name from my database and then @ “profile/NAME” it will display his “stats” and such..

I’ve tried to fix this, but no luck.
I think this will be pretty easy.

Thanks,
 
It's called Segment URL, if there is index.php following it.

Anyway here u go
$this->load->library('url');
$first = $this->uri->segment(1);
$second = $this->uri->segment(2);

or within a controller

public function example($first, $second) {}
 
@chojrak CodeIgniter already have this function, i'm looking for codeigniter code.
It's called Segment URL, if there is index.php following it.

Anyway here u go
$this->load->library('url');
$first = $this->uri->segment(1);
$second = $this->uri->segment(2);

or within a controller

public function example($first, $second) {}


Okay, i'll try this

Edit: "$this->load->library('url');" You mean URI, right?

Anyways; How should I now write @ my view? ;o
 
Last edited:
@chojrak CodeIgniter already have this function, i'm looking for codeigniter code.



Okay, i'll try this

Edit: "$this->load->library('url');" You mean URI, right?

Anyways; How should I now write @ my view? ;o

No, when you load URL library, you have access to it through URI.

In a view, you can put this code in controller and send it to the view, or you can load CodeIgniter instance through $CI =& load_instance(); and then you can load this library, but instead of using $this you have to use $CI;
 
No, when you load URL library, you have access to it through URI.

In a view, you can put this code in controller and send it to the view, or you can load CodeIgniter instance through $CI =& load_instance(); and then you can load this library, but instead of using $this you have to use $CI;


An Error Was Encountered

Unable to load the requested class: url


Tho, I don't really understand. This is my view atm:
PHP:
<?php
$this->uri->segment(1);
$query = $this->db->query("SELECT * FROM members WHERE user = '-'") or die("kunde ej hitta användaren");
foreach ($query->result() as $row)
{
	echo $row->level;
}
?>
And how should it take username from database?
 
This is wrong.

First of all, you don't do SQL queries within views, but within models, you can't have $this variable within view as well, as this goes for classes etc
Next thing is, codeigniter has really nice documentation, so you can learn how to do it from there: Welcome to CodeIgniter : CodeIgniter User Guide
And yeah, maybe this is a helper not library, I forgot. Also you can read Modern AAC's code, maybe you will learn something about it from there.
 
This is wrong.

First of all, you don't do SQL queries within views, but within models, you can't have $this variable within view as well, as this goes for classes etc
Next thing is, codeigniter has really nice documentation, so you can learn how to do it from there: Welcome to CodeIgniter : CodeIgniter User Guide
And yeah, maybe this is a helper not library, I forgot. Also you can read Modern AAC's code, maybe you will learn something about it from there.

Okay, I'll read their documentation & Modern AAC's code. Thanks :]

I'll come up with result, later on also.

Edit: Now it works.
PHP:
$first = $this->uri->segment(3);
&
PHP:
$query = $this->db->query("SELECT * FROM members WHERE user = '$first'") or die("error");
 
Last edited:
Back
Top