Welcome Guest, Not a member yet? Register   Sign In
Traditional Mysql Code
#1

[eluser]rochellecanale[/eluser]
hey guys just want to ask. Can i integrate the traditional Mysql command in my script?
Like:
Code:
$connect = mysql_connect('localhost','root','','databasename')
or die mysql_error();

$query = "SELECT * FROM sampletable";
while(($row = mysql_fetch_array($query)) !== FALSE){
     echo $row['id'].
     .
     .
     .
     .
}

because in one of my file i want to retrieve my information using this method... And together with that i want to store my information in a multidimensional array inside my while loop.
#2

[eluser]xerobytez[/eluser]
Sure, you can...but why would you want to? CodeIgniter's active record system makes working with databases so much easier and cleaner. Here is an example of what you are doing in active record.

Code:
$result = $this->db->get('sampletable');

if ($result->num_rows()) {
    foreach($result->result_array() as $row) {
        echo $row['id'];
    }
}
#3

[eluser]CroNiX[/eluser]
Have you read the userguide for using the database?
Controller
Code:
//get data from database
$data['tabledata'] = $this->db->get('sampletable')->result_array();
//send it to a view
$this->load->view('some_view', $data);

View
Code:
foreach($tabledata as $row)
{
  echo $row['id'];
}
#4

[eluser]rochellecanale[/eluser]
yes i have read that but the problem is i am implementing a shopping cart which is plugin. And that plugin is written in traditional format. And for retrieving cart list is actually stored in a (two dimensional/multidimensional array) My problem is i cant retrieve my data in my database. I tried active record but it gives me a result of undefined index. i put my array inside the foreach loop.
#5

[eluser]CroNiX[/eluser]
Why not use a cart system that is already written for CI, or use CI's own cart system? You're going to fight an uphill battle here.
#6

[eluser]rochellecanale[/eluser]
yes i want to do that but my problem is it displays all the product details. all i want to do is have a search box that can navigate the selected product. Like in the grocery. When the barcode reader scanned the product it retrieves the product result. How can i do that?




Theme © iAndrew 2016 - Forum software by © MyBB