srijon Posted August 19, 2011 Share Posted August 19, 2011 I have a page called list.php which retrieves from database and shows all the student names with their respective ids in a list. In raw php, this is how I have done this- include("connect.php"); $query = "SELECT * FROM marks "; $result = mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); if ($num > 0 ) { $i=0; while ($i < $num) { $studentname = mysql_result($result,$i,"studentname"); $studentid = mysql_result($result,$i,"studentid"); ?> And then--- <a href="studentprofile.php?studentid=<? echo $studentid?>"><? echo $studentname ?></a> <? ++$i; } } else { echo "No Record Found"; } ?> When a user clicks on any of the student names, it takes the user to the page of that particular student and in that page I have a code like following- include("connect.php"); $number = $_GET['studentid']; $qP = "SELECT * FROM student WHERE studentid = '$number' "; $rsP = mysql_query($qP); $row = mysql_fetch_array($rsP); extract($row); $studentid = trim($studentid); $studentname = trim($studentname); $studentgender = trim($studentgender); The above code is working just fine. Now as far as I know $_get is disable in Codeigniter. But how to do the exact same thing that I mentioned above in codeigniter if $_get is disabled ? I went through some tutorials on alternative way of using $_get, but I didn't understand those well. Would you please kindly help? Thanks in Advance codeigniter Quote Link to comment https://forums.phpfreaks.com/topic/245185-having-problem-with-_get-in-codeigniter/ Share on other sites More sharing options...
AyKay47 Posted August 19, 2011 Share Posted August 19, 2011 you can enable it.. http://stackoverflow.com/questions/2043070/enabling-get-in-codeigniter Quote Link to comment https://forums.phpfreaks.com/topic/245185-having-problem-with-_get-in-codeigniter/#findComment-1259374 Share on other sites More sharing options...
srijon Posted August 19, 2011 Author Share Posted August 19, 2011 Thanks for you reply. But I don't want to enable it, all I am looking for is what to use instead of this-" $number = $_GET['studentid']; " Please kindly check the code I submitted again. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/245185-having-problem-with-_get-in-codeigniter/#findComment-1259383 Share on other sites More sharing options...
thehippy Posted August 19, 2011 Share Posted August 19, 2011 POST, GET, COOKIE and SESSION are all in the input object Please encapsulate your code in php or code bbcode tags in the future. Quote Link to comment https://forums.phpfreaks.com/topic/245185-having-problem-with-_get-in-codeigniter/#findComment-1259395 Share on other sites More sharing options...
ignace Posted August 19, 2011 Share Posted August 19, 2011 The URL would look like: index.php/student/get/1 get in the URL has nothing to do with the variable. And you would access it like: class Student extends Controller { public function get($id) { $this->load->model('studentmodel'); $student = $this->studentmodel->find($id); $this->load->view('student/info', array('student' => $student)); } } This is how CI works. Quote Link to comment https://forums.phpfreaks.com/topic/245185-having-problem-with-_get-in-codeigniter/#findComment-1259484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.