malanno Posted August 14, 2015 Share Posted August 14, 2015 Hi, I was wondering if someone could help me. I included a sample of my database... This is what I got... <?php $row = 1; if (($handle = fopen("jobstatus2.txt", "r")) !== FALSE) { echo '<table class="sortable" border="0">'; while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { $num = count($data); if ($row == 1) { echo '<thead><tr>'; }else{ echo '<tr>'; } for ($c=0; $c < $num; $c++) { //echo $data[$c] . "<br />\n"; if(empty($data[$c])) { $value = " "; }else{ $value = $data[$c]; } if ($row == 1) { echo '<th>'.$value.'</th>'; }else{ echo '<td>'.$value.'</td>'; } } if ($row == 1) { echo '</tr></thead><tbody>'; }else{ echo '</tr>'; } $row++; } echo '</tbody></table>'; fclose($handle); } ?> It works perfectly for what I'm doing. But it only works perfectly from a database I build just for this... The problem is the data I need is part of a bigger database and I just need a small part that I colored in yellow. Can someone help me out, on this? Any help would be appreciated. Thanks William Quote Link to comment Share on other sites More sharing options...
Barand Posted August 14, 2015 Share Posted August 14, 2015 while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) { if ($row > 1 && substr($data[0],0,3) != 'JOB' ) continue; // add this // rest of you loop code here } Better method would be to extract just the data you need from your database. Quote Link to comment Share on other sites More sharing options...
malanno Posted August 14, 2015 Author Share Posted August 14, 2015 It does work, but for some reason it picks up the first line of the database and lists that. So I added a blank line to the first line and it works great. If I can go to the wisdom well one more time I would like to ask.... Is there any way to pick and choose which columns are to be used? William Quote Link to comment Share on other sites More sharing options...
Barand Posted August 14, 2015 Share Posted August 14, 2015 $data[0] is the first column, $data[1] the second and so on. Quote Link to comment Share on other sites More sharing options...
malanno Posted August 14, 2015 Author Share Posted August 14, 2015 ahhhhh, that's ingenious, thank you very much. I will pay it forward Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.