Skip to main content

Show Posts

This section allows you to view all Show Posts made by this member. Note that you can only see Show Posts made in areas you currently have access to.

Messages - Goto

1
Questions / Re: How to get the number of rows in a table
Thank you.

I had finally managed to do it.
Code: [Select]

//query the database and return the results
$params = array($modeldata['Project_ID']);
$arr    = $db->rawQuery("SELECT Learner_ID FROM learners WHERE Project_ID = ?", $params);
foreach ($arr as $row){
$table_data = array(
"Learner_ID" => $row['Learner_ID'],
    "Project_ID" => $modeldata['Project_ID'],
    "Class_ID" => $rec_id
);

$db->insert("attendance", $table_data);

};
2
Questions / How to get the number of rows in a table
Hello everyone
I am failing to get all records(Rows) from my “learners” table to be inserted into the “attendance” table. Please help!
My first query is not returning the number of rows from the table.
Help... How to get the number of rows in a table
Code: [Select]
$line = $db->rawQueryValue("SELECT COUNT(*) FROM learners");

for ($i = 1; $i <= $line; $i++){

//query the database and return a single field value
$db->where("Project_ID", $modeldata['Project_ID']);
$db->where("Learner_ID", $i);
$value = $db->getValue("learners", "Learner_ID");

$table_data = array(
    "Learner_ID" => $value,
    "Project_ID" => $modeldata['Project_ID'],
    "Class_ID" => $rec_id
);

$db->insert("attendance", $table_data);

};