Welcome Guest, Not a member yet? Register   Sign In
need help about anchor
#1

[eluser]doforumda[/eluser]
hi

I need to use this kind of link "www.example.com/post/4"
The problem is I am currently getting this kind of url but how can I deal with the id, i.e. 4 in this case, in my controller.

here is my code

Code:
<?php foreach($rows as $r) : ?>
        <div id="products_contents">    
            <div class="thumb"></div>
            &lt;?php echo "<div><a id='title' href=''>" . $r->title . "</a></div>"; ?&gt;
            &lt;?php //echo "<div>" . $r->desc . "</div>"; ?&gt;
            &lt;?php echo "<div>Added by: " . $r->owner . "</div>"; ?&gt;
            &lt;?php echo "<div>Category: " . $r->category . "</div>"; ?&gt;
            &lt;?php echo "<div id='price'>Price: " . $r->price . "</div>"; ?&gt;
            &lt;!-- <a id="contact">productid; ?&gt;">Contact Owner</a> --&gt;
            &lt;?php echo anchor('contact/'.$r->productid,'Contact Owner', array('id' => 'contact')); ?&gt;
        </div>&lt;!-- products_contents --&gt;
        &lt;?php endforeach; ?&gt;

in controller i am doing this
Code:
function contact($id) {
     $this->load->view('contact_owner', $id);
}
help please
#2

[eluser]appleboy[/eluser]
Hi,

I think you must read Generating Query Results first.

Please referrer the following example code: This function returns a single result row

Code:
$query = $this->db->query("YOUR QUERY");

if ($query->num_rows() > 0)
{
   $row = $query->row_array();

   echo $row['title'];
   echo $row['name'];
   echo $row['body'];
}
#3

[eluser]doforumda[/eluser]
anyone who can help me?
#4

[eluser]Taps[/eluser]
[quote author="doforumda" date="1311716346"]anyone who can help me?[/quote]
example.com/blog/comments/id/
hosting/controller/function/id

Controller
Quote:&lt;?php
class blog extends CI_Controller {

public function index()
{
echo 'Hello World!';
}

public function comments($id)
{
echo $id;
}
}
?&gt;
#5

[eluser]doforumda[/eluser]
I am trying that way but it shows this error

Code:
404 Page Not Found
The page you requested was not found.
#6

[eluser]appleboy[/eluser]
[quote author="doforumda" date="1311725246"]I am trying that way but it shows this error

Code:
404 Page Not Found
The page you requested was not found.
[/quote]

Please show your controller source code or show it via http://codepad.org




Theme © iAndrew 2016 - Forum software by © MyBB