html - How to add headers,checkboxes and submit/cancel button to form table php? -


i need create form extracts data csv file, amongst other types of data have on code.

<html> <body> <table border=1px solid black> <?php $fp=fopen('sample.csv','r'); while(($data=fgetcsv($fp,1000,";"))!==false){     $user=$db->get_record('user',array('username'=>trim($data[0])));     echo '<tr><td>' . $data[0] . '</td><td>' . $user->firstname . '</td><td>' . $user->lastname . '</td><td>' . array_shift($dataclipnumber) . '</td><td>' . $data[1] .'</td><td>'.whatcourse(array_shift($dataclipcourse)).  '</td></tr>'; } fclose($fp);  ?> </table> </body> </html> 

here's output far: form2

i add headings each column. tried put th tags between tr , td, showed column instead. other that, add checkboxes next usernames( firstcolumn) , can come checked default? lastly, put submit button saves usernames checkedmarked , calls enrollment code (doing moodle plugin of enrollment).

thank you.

edit: worked :) although button still missing. words ',~ on them. 1 in picture nĂºmero. way solve in headings?

edit 2: since i'm doing on moodle, removed variable gave greyish it, since interfering buttons. no. using smaller example:

smaller table

you need add header outside of iteration;

<form id="form">     <table border=1px solid black>         <tr>             <td>#</td>             <td>column-1</td>             <td>column-2</td>             <td>column-3</td>             <td>column-4</td>             <td>column-5</td>             <td>column-6</td>         </tr>         <?php         $fp=fopen('sample.csv','r');         while(($data=fgetcsv($fp,1000,";"))!==false){             $user=$db->get_record('user',array('username'=>trim($data[0])));             echo '<tr>' .                 '<td><input type="checkbox" name="username[]" value="' . $data[0] . '" checked="checked"/></td>' .                 '<td>' . $data[0] . '</td><td>' . $user->firstname . '</td>' .                 '<td>' . $user->lastname . '</td>' .                 '<td>' . array_shift($dataclipnumber) . '</td>' .                 '<td>' . $data[1] .'</td>' .                 '<td>' . whatcourse(array_shift($dataclipcourse)).  '</td>' .             '</tr>';         }         fclose($fp);          ?>     </table>     <a href="javascript:;" onclick="document.getelementbyid('form').submit();">save</a> </form> 

edit: need put ;

<meta http-equiv="content-type" content="text/html; charset=utf-8"> 

in html headers section fix special character view on page


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -