-2

and i want the cell file name size of the file etc.... to be blue and the row to be a different color with hover! when i cross with mouse over rows i want to change the colors. i tried with css and all the toutorials from internet. the header i want to be one color. But no luck ... any ideea?

Sorry for my english!!

Best regards!

    // connect to the database
    include('database.php');

    // number of results to show per page
    $per_page = 3;

    // figure out the total pages in the database
    $result = mysql_query("SELECT * FROM files");
    $total_results = mysql_num_rows($result);
    $total_pages = ceil($total_results / $per_page);

    // check if the 'page' variable is set in the URL (ex: view-paginated.php?page=1)
    if (isset($_GET['page']) && is_numeric($_GET['page']))
    {
        $show_page = $_GET['page'];

        // make sure the $show_page value is valid
        if ($show_page > 0 && $show_page <= $total_pages)
        {
            $start = ($show_page -1) * $per_page;
            $end = $start + $per_page; 
        }
        else
        {
            // error - show first set of results
            $start = 0;
            $end = $per_page; 
        }       
    }
    else
    {
        // if page isn't set, show first set of results
        $start = 0;
        $end = $per_page; 
    }

    // display pagination

    for ($i = 1; $i <= $total_pages; $i++)
    {
        echo "<a href='view.php?page=$i'>$i</a> ";
    }
    echo "</p>";

    // display data in table
    echo "<table class=' tablesorter' cellpadding='1'>";
    echo 
    "<tr><th>File name</th> <th>Size of file</th> <th>Date added</th> <th>Hits/Downloads</th<th>Download file</th>
    </tr>";

    // loop through results of database query, displaying them in the table 
    for ($i = $start; $i < $end; $i++)
    {
        // make sure that PHP doesn't try to show results that don't exist
        if ($i == $total_results) { break; }

        // echo out the contents of each row into a table
        echo "<tr>";
        echo '<td>' . mysql_result($result, $i, 'file_id') . '</td>';
        echo '<td>' . mysql_result($result, $i, 'file_name') . '</td>';
        echo '<td>' . mysql_result($result, $i, 'file_category') . '</td>';
        echo '<td>' . mysql_result($result, $i, 'file_date') . '</td>';
        echo '<td>' . mysql_result($result, $i, 'file_version') . '</td>';
        echo '<td>' . mysql_result($result, $i, 'file_link') . '</td>';

        echo "</tr>"; 
    }
    // close table>


    // pagination

?

>

  • 2
    Please [don't use `mysql_*`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php?rq=1); the `mysql_*` functions are outdated, [deprecated](http://us3.php.net/manual/en/intro.mysql.php), and insecure. Use [`MySQLi`](http://us3.php.net/manual/en/book.mysqli.php) or [`PDO`](http://us3.php.net/manual/en/intro.pdo.php) instead. – elixenide May 23 '16 at 00:32
  • Thanks for notice that :) – Tanase Catalin Nicolae May 23 '16 at 00:37

1 Answers1

1

Why don't you just add classes to your rows? Like this:

// display data in table
echo "<table class=' tablesorter' cellpadding='1'>";
echo 
"<tr class='tableHeadRow'><th>File name</th> <th>Size of file</th> <th>Date added</th> <th>Hits/Downloads</th<th>Download file</th>
</tr>";

// loop through results of database query, displaying them in the table 
for ($i = $start; $i < $end; $i++)
{
    // make sure that PHP doesn't try to show results that don't exist
    if ($i == $total_results) { break; }

    // echo out the contents of each row into a table
    echo "<tr class='tableRow'>";
    echo '<td>' . mysql_result($result, $i, 'file_id') . '</td>';
    echo '<td>' . mysql_result($result, $i, 'file_name') . '</td>';
    echo '<td>' . mysql_result($result, $i, 'file_category') . '</td>';
    echo '<td>' . mysql_result($result, $i, 'file_date') . '</td>';
    echo '<td>' . mysql_result($result, $i, 'file_version') . '</td>';
    echo '<td>' . mysql_result($result, $i, 'file_link') . '</td>';

    echo "</tr>"; 
}
// close table>

And then in css just put styling for those two classes .tableHeadRow and .tableRow

Jakob
  • 3,493
  • 4
  • 26
  • 42