Jump to content

problems with php... targeting specific data in a semicolon table in an external text file...


malanno

Recommended Posts

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

post-179098-0-76327700-1439576386_thumb.png

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.