Wagtail Posted September 9, 2014 Share Posted September 9, 2014 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 More sharing options...
HartleySan Posted September 9, 2014 Share Posted September 9, 2014 No, you cannot pull out sections of an include file. As you suggested, you need to either put the code within functions, or put the code in separate include files. 1 Link to comment Share on other sites More sharing options...
Wagtail Posted September 9, 2014 Author Share Posted September 9, 2014 Ok, thanks for getting back to me. Just wanted to make sure. Link to comment Share on other sites More sharing options...
Recommended Posts