Need some guidance, I want to save multiples values from a html table into a mysql database

AlexTCGPro

Member
Hey guys.
I have this table 'students', with multiple fields.
I made an article with php code and created a simple html table with some of those values, that generates a row every time a condition is meet, plus two new fields I want to be stored, a button an a textarea.

So, my code is like this:

Code:
<?php
$list = '1,2,3,4,5,6'
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('id', 'name', 'lastname', 'picture'))->from('students')->where('id IN (' . $list . ') ')->order('lastname ASC');
$db->setQuery($query);
$studs = $db->loadObjectList();
$linecountStu++;
echo '<table>';
foreach ($studs as $stud) {
echo '<tr id="' . $stud->id . '">';
echo '<td>#' . $linecountStu++ . '</td>';
echo '<td>' . $stud->name . ' ' . $stud->lastname . '</td>';
echo '<td><img src="' . $stud->picture . '"/></td>';
echo '<td><textarea name="text" rows="3" placeholder="Comment..." maxlength="500" style="resize: none;"></textarea></td>';
echo '<td><button onclick="button(this)" value="0"></button></td>';
echo '</tr>';
}
echo '</table>';
?>

I was thinking on just making a button that immediately inserts those values to a database, student id, name and lastname, textarea and the value of the button (which changes once clicked), but I can't seem to get any of those values with php. Can you give me a hand?

Basically, for each table row insert the values of its <td>.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top