Jump to content
Larry Ullman's Book Forums

Return Specific Sections From An "include" File


Recommended Posts

Hello everyone,

 

this is a quick question about the PHP include() function. Is it possible to pull in specific sections of an include file? Such as:  include ("inc/menu.php #div1");

 

The following code snippets are both in the same include file but they need to be called separately. Should I wrap these in functions? The table can probably be assigned to a variable.

# Script 10.5 - #5
// Determine the sort...
// Default is by registration date.
$sort = (isset($_GET['sort'])) ? $_GET['sort'] : 'rd';

// Determine the sorting order:
switch ($sort) {
    case 'ln':
        $order_by = 'last_name ASC';
        break;
    case 'fn':
        $order_by = 'first_name ASC';
        break;
    case 'rd':
        $order_by = 'registration_date ASC';
        break;
    default:
        $order_by = 'registration_date ASC';
        $sort = 'rd';
        break;
}
echo '<table align="center" cellspacing="0" cellpadding="5" width="75%">
<tr>
    <td align="left"><b>Edit</b></td>
    <td align="left"><b>Delete</b></td>
    <td align="left"><b><a href="view_users.php?sort=ln">Last Name</a></b></td>
    <td align="left"><b><a href="view_users.php?sort=fn">First Name</a></b></td>
    <td align="left"><b><a href="view_users.php?sort=rd">Date Registered</a></b></td>
</tr>
';

Thanks in advance!

Link to comment
Share on other sites

 Share

×
×
  • Create New...