I am having Parse error: syntax error, unexpected 'selected' (T_STRING), expecting ',' or ';'

Codes here !

Moderators: egami, macek, gesf

Post Reply
prohor
New php-forum User
New php-forum User
Posts: 8
Joined: Sun Sep 11, 2016 8:38 am

Fri Mar 31, 2017 9:22 am

how I can mark selected pagination page for the following code? I have tried with

Code: Select all

<?php if($page===$i) {echo ' class="selected"';}?>
in the line

Code: Select all

echo "<a href='index3.php?page=".$i."' class='navigation_item selected_navigation_item'>".$i."</a>";
with the help of css using 'selected' class but error occurring "Parse error: syntax error, unexpected 'selected' (T_STRING), expecting ',' or ';' " else it is now working. where i want to place "selected" class is

Code: Select all

for ($i=1; $i<=$totalPages; $i++) {
echo "<span class='navigations_items_span'>";
//if($page===$i) {echo 'class="selected"',"<b>Page </b>";};
echo "<b>Page </b>";
echo "<a href='index3.php?page=".$i."' class='navigation_item selected_navigation_item'>.<?php if($page===$x) {echo ' class="selected"';}?>. ".$i."</a>";

echo "</span>";

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 711
Joined: Mon Feb 22, 2016 5:52 pm

Fri Mar 31, 2017 10:08 am

Code: Select all

.<?php if($page===$x) {echo ' class="selected"';}?>.
Doesn't make any sense inside an echo statement.

Post Reply