如何在php中获取Excel的列名

时间:2018-12-10 10:27:02

标签: php excel phpexcel

我的列正在根据我的测试名称..如何从excel列中获取测试名称。我想要我的excel标头,以便我可以将测试名称与相应结果保存在我的数据库中

这是我的代码

variables

我正在使用$ insert_csv获取列的值。但是我将如何明智地获得测试名称

echo'<table width="80%" cellpadding="5" cellspacing="5" align="center" border="1" class="table" id="temtable">
        <tr class="bold" style="color:#fff;background-color:#'.$_SESSION['tclr'].';" >
                            <th style="width:20px;">#</th>
                            <th>Name</th><th>Userid</th>';

 $test=$obj->listDirectQuery("SELECT  * FROM `evv`  WHERE status = '2'");   
$testnames=$obj->listDirectQuery("select id,test_name from test where id in(".$test[0]['tests'].")");   
                    foreach($testnames as $testname){ 
                            echo'<th>'.$testname['test_name'].'-('.$testname['id'].')</th>'; }
                            echo'</tr>'; 


                            $users=$obj->listDirectQuery("SELECT * from users where status = '2'");
                            $i=1;
                            foreach($users as $user){
                            echo '<tr><td>'.$i.'</td>';
                            echo '<td  style="text-align:center">'.$user['first_name'].''.$user['last_name'].'</td><td>'.$user["id"].'</td></tr>';$i++;
                            }
                            //echo'<td colspan="5" style="text-align:center">';



                            echo '</table>';
我要获取的

$sql="INSERT INTO `prescription` (user_id,test_id,test_results)VALUES(".$ids[0]['id'].",".$tid.",".$insert_csv['test_results'].",)"; 值是我的excel标头中的测试名称,该名称根据我分配的测试是动态的

0 个答案:

没有答案