php - Button doesn't appear after while cycle even though it works if i put it before cycle -


i have footer.php admin button in , when include @ end of page button doesn't appear.. if put before code:

<?php if ($row["rights"]=="2"):?> <div id='cssmenu-admin'> <ul> <li name='admin' class='active'><a href='administration.php'><span>admin</span></a></li> </ul> </div> <?php endif; ?> 

from footer.php before while cycle works should.

this footer.php file:

<div id="footer"> <hr>copyrighted (c) 2014 djdanas@gmail.com<br> <?php if ($row["rights"]=="2"):?> <div id='cssmenu-admin'> <ul> <li name='admin' class='active'><a href='administration.php'><span>admin</span></a></li> </ul> </div> <?php endif; ?> </div> <br><hr> 

and page file:

<!doctype html>  <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>pagrindinis</title> <link href="css/stilius.css" rel="stylesheet" type="text/css"/> <link href="css/menu.css" rel="stylesheet" type="text/css"/> </head> <body>  <?php require("includes/validate.php");?> <?php require("includes/stilius.php");?>  <?php require("includes/connection_to_db.php");  $sql = "select prekės.* , concat(vartotojai.name) v_name     prekės      left join vartotojai     on vartotojai.v_id=prekės.v_id     order prekės.date      desc limit 8";     $result = mysql_query("$sql"); ?>  <?php mysql_close(); ?>  <?php while ($row = mysql_fetch_assoc($result)) : ?>     <?php $image = '<td><img src="data:image/jpeg;base64,'.base64_encode($row['image']).'" name="pix" width="270" height="200"/></td>' ?>     <table class="two">     <th><?php echo $row['name'] ?></th>     <th>prekės savininkas: <?php echo $row['v_name']?></th>             <th><input type="button" value="mainyti"></th>             <tr>             <?php echo $image?>             <td><textarea disabled style="resize:none; background-color:white" name="about" rows="12" cols="65"><?php echo $row['specs']?></textarea><td>        </table> <?php endwhile; ?>    <?php require("includes/footer.php");?>  </body> </html> 

edit:

ok, solved problem adding new variable

$rights = $row['rights']; 

right after

<!doctype html>  <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>pagrindinis</title> <link href="css/stilius.css" rel="stylesheet" type="text/css"/> <link href="css/menu.css" rel="stylesheet" type="text/css"/> </head> <body>  <?php require("includes/validate.php");?> <?php require("includes/stilius.php");?> 

in page file , changed 1 line in footer.php file from

<?php if ($row['rights']=="2"):?> 

to

<?php if ($rights="2"):?> 

now it's working charm :)

i'll take stab in dark here , test

if ($row["rights"]=="2") 

means checking see if user logged in has "rights" of 2?

then when loop through query...

while ($row = mysql_fetch_assoc($result)) 

you overwriting $row variable. whatever thought in there begin with, isn't anymore. should use different variable either user or looping through query.

edit: it's possible variable isn't in scope once testing it. try using print_r($row) in footer.php see inside of $row -- should help.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -