Hi guys… I am a php newbie. I followed a php CMS tutorial on youtoube: http://www.youtube.com/watch?v=nuOUyFimtQE&feature=list_related&playnext=1&list=PL11D6E5B9CA126A57
I am using and css class to style the buttons, and trying to implement a for loop to highlight the current button
I created the cms but they don’t explain how to highlight the current page button. Below is the code. Just concentrate on the NAVIGATION area at the bottom of the code. Any help will be greatly appreciated!
Thanks in advance for your help!
[php]
<?php //session_start();/* Created by Adam Khoury @ www.developphp.com */
require_once “scripts/connect_to_mysql.php”;
// DETERMINE which page ID to USE in our query below ********************************************
if (!isset($_GET[‘pid’])) {
$pageid = ‘1’;
} else {
//$pageid = ereg_replace("[^0-9]", “”, $_GET[‘pid’]); // deprecated function
$pageid = preg_replace(’#[^0-9]#i’, ‘’, $_GET[‘pid’]); // filter everything but numbers for security(new)
//preg_replace($pattern, $replacement, $string);//preg_replace() Function structure
}
// Query the body section for the proper page***********
$sqlCommand = “SELECT pagebody FROM pages WHERE id=’$pageid’ LIMIT 1”;
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$body = $row[“pagebody”];
}
mysqli_free_result($query);
//********* Query the module data for display **************
$sqlCommand = “SELECT modulebody FROM modules WHERE showing=‘1’ AND name=‘footer’ LIMIT 1”;
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$footer = $row[“modulebody”];
}
mysqli_free_result($query);
//Query the module data for display******
$sqlCommand = “SELECT modulebody FROM modules WHERE showing=‘1’ AND name=‘custom1’ LIMIT 1”;
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
while ($row = mysqli_fetch_array($query)) {
$custom1 = $row[“modulebody”];
}
mysqli_free_result($query);
/************************
NAVIGATION****
*************************/
$sqlCommand = “SELECT id, linklabel FROM pages WHERE showing=‘1’ ORDER BY id ASC”;
$query = mysqli_query($myConnection, $sqlCommand) or die (mysqli_error());
$record_count = mysqli_num_rows($query);//****
$menuDisplay = ‘’;
while ($row = mysqli_fetch_array($query)) {
$pid = $row[“id”];
$linklabel = $row[“linklabel”];
//*Prepare to Show and Highlight buttons
HERE’S THE TRICKY PART FOR ME******
$per_page=‘1’;
for ($x=0; $x < $record_count; $x=$x+$perpage)
if($pid!=$x){
//$pid = mysql_real_escape_string($pid);
//$menuDisplay .= '<a href="index.php?pid=' . $pid . '">' . $linklabel . '</a><br />';//original link
$menuDisplay .= '<ul class="jj"> <a href="index.php?pid='.$pid. '">' . $linklabel.'' . '</a></li><br />';}
else $pid=$pid/$pid;
$menuDisplay .= '<li class="selectedlink"><a href="index.php?pid='.$pid. '">' . $linklabel.'' . '</a></li><br />';
}
mysqli_free_result($query);
mysqli_close($myConnection);
?>[/b]
[/php]