Jump to content

php hovering down a dynamic table and on hover displaying data in header


malanno

Recommended Posts

Hi, I have all the elements I need but I need to connect the dots...

 

Situation...

 

 

I have a job table that is brought in with this variable

<?php

$row = 1;
if (($handle = fopen($statfile, "r")) !== FALSE) {

    echo '<table class="sortable" border="0">';

    while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
        if (substr($data[0],0,3)!='HDR' && substr($data[0],0,3) != 'JOB' )  continue;
        $num = count($data);
        if (substr($data[0],0,3)=='HDR') {
            echo '<thead><tr>';
        }else{
            echo '<tr>';
        }
        for ($c=1; $c <= 4; $c++) {
            //echo $data[$c] . "<br />\n";
            if(empty($data[$c])) {
               $value = " ";
            }else{
               $value = trim($data[$c]);
            }
        if (substr($data[0],0,3)=='HDR') {
                echo '<th style="text-align:center">'.$value."</th>\n";
            }else{
                if ($c==1) {
                echo '<td style="text-align:center"><a href="http://wfbscd13/cgi-bin/aplog.cgi?type=job&logname='.$value.'&hostname='.$host.'" target="_blank">'.$value."</a></td>\n";

                }else{
                echo '<td style="text-align:center">'.$value."</td>\n";
                }
            }
        }

        if (substr($data[0],0,3)=='HDR') {
            echo '</tr></thead><tbody>';
        }else{
            echo '</tr>';
        }
        $row++;
    }

    echo '</tbody></table>';
    fclose($handle);
}
?>

I attached a picture to show my screen... The right hand div with the list of jobs is on the right. I have it set so I can hover over the row and it highlights a row. Here is that code... It is jquery (1.9.1)

<script type="text/javascript"> 
         
$("tr").not(':first').hover( 
  function () { 
    $(this).css("background","#d3d3d3"); 
  }, 
  function () { 
    $(this).css("background",""); 
  } 
); 
         
</script> 

And finally the php query for the header....

<?php

$row = 1;
if (($handle = fopen("status.txt", "r")) !== FALSE) {
    
    echo '<table class="sortable" border="0">';
    
    while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
		if ($row > 1 && substr($data[0],0,3) != 'JOB' ) continue;
        $num = count($data);
        if ($row == 1) {
            echo '<thead><tr>';
        }else{
            echo '<tr>';
        }      
        for ($c=4; $c <$num; $c++) {
            //echo $data[$c] . "<br />\n";
if(empty($data[$c])) {
               $value = " ";
            }else{
               $value = trim($data[$c]);
            }
        if (substr($data[0],0,3)=='HDR') {
                echo '<th style="text-align:center">'.$value."</th>\n";
            }else{
                if ($c==1) {
                echo '<td style="text-align:center">'.$value."</td>\n";

                }else{
                echo '<td style="text-align:center">'.$value."</td>\n";
                }
            }
        }

        if (substr($data[0],0,3)=='HDR') {
            echo '</tr></thead><tbody>';
        }else{
            echo '</tr>';
        }
        $row++;
    }

    echo '</tbody></table>';
    fclose($handle);
}
?>

What I need is to show this last query in the header on hover of the first query.... But I can't seem to connect the dots... Can anyone help me?

post-179098-0-34353900-1440092366_thumb.png

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.