Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want to hide element in my website. I have 2 level access (ad,op). If I logged as sp I can acces Buy, Try, List Upload, and Upload. If I logged as ad, I can access Buy, Try, and List Upload. and not logged, can access Buy and Try.
My code : http://pastebin.com/SvZmzmxK
<p style="text-align:justify;"> </p>
<strong>Buy </strong> <strong> Try</strong>
<?php if ($level=='super_admin') {?>
<strong> List Upload</strong></br></p>
<strong> Upload</strong></br></p>
<?php } elseif($level=='admin') {?>
<strong> List Upload</strong></br></p>
<strong> Upload</strong></br></p>
<?php } ?>
Looking at your code, this is probably just what you are looking for:
<?php
if ($level=='super_admin')
echo "<strong> List Upload</strong>";
else if elseif($level=='admin')
echo "<strong> List Upload</strong></br></p>
<strong> Upload</strong></br></p>";
?>
I would recommend putting your php in a format like this (using echo) since it keeps your code easier to read and maintain.
I also advice you to look at your html knowledge: </br> and </p> can't just be used liked that.
You can try like this:
<p style="text-align:justify;"> </p>
<strong>Buy </strong> <?php //Buy for all; ?>
<strong> Try</strong> <?php //Try for all; ?>
<?php if( in_array($level,array('super_admin','admin')) ){ ?>
<strong> List Upload</strong> <?php //Buy|Try|List Upload for ad+sp; ?>
<?php if($level=='admin'): ?>
<strong> Upload</strong> <?php //Upload is only for admin(ad); ?>
<?php endif; ?>
<?php } ?>
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
my php code works fine on local server but does not execute on web server
some of the codes are working.
the code is given down and please tell me problem with the code.
<?php
include("/connect.php");
session_start();
$_SESSION['title']="Portfolio | Mactros Inc.";
include("header.php");
?>
<div>
<center>
<font size=7 class="top">
Portfolio<br />
</font>
<font style="color: #aeafb1;">Home -> Portfolio</font>
</center>
</div>
<div style="height: 650px; margin-top: 10px;">
<?php
$sql = "select * from project";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
?>
<div class="portfolio">
<center>
<img src="<?php echo $row["pic"]; ?>" class="port">
<font size=5><?php echo $row["name"];?></font><br>
<font><?php echo $row["type"];?></font>
</center>
</div>
<?php }?>
</div><?php include("footer.php");?>
in this code gets executed other gets ignored
<?php
include("/connect.php");
session_start();
$_SESSION['title']="Portfolio | Mactros Inc.";
include("header.php");
?> <div>
<center>
<font size=7 class="top">
Portfolio<br />
</font>
<font style="color: #aeafb1;">Home -> Portfolio</font>
include("/connect.php");
This is an absolute path, I don't think your script is at the root of your filesystem, use a relative path instead, and don't disable errors.
Write this line of code at top of you script file to show errors which are occurring into script.
ini_set('display_errors', 1);
error_reporting(E_ALL);
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have following data in mysql, and I want to echo in this format:
Data:
Name,Image URL,Link
I want to print it dynamically like this : http://screensaver.cf/screensavers.php
I don't know user's screen width, still I want it to appear as much as possible in width.
How can I do this in html and PHP?
My code:
<?php
require("config.php");
?>
<div id="main-wrap">
<div class="container">
<div id="main">
<div id="content"><div id='wsite-content' class='wsite-elements wsite-not-footer'>
<div class="paragraph" style="text-align:left;">
<?php
$sql='SELECT * FROM `games` where 1=1';
$data = mysql_query($sql);
echo '<h4 class="result">Result:</h4>';
while($row = mysql_fetch_row($data)){
$table=WHAT TO DO HERE TO MAKE IT LOOK LIKE THAT???????
echo $table;
echo '<br><br>';
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
include("footer.php");
?>
P.S I know mysql is depreciated and I am constantly working to learn Mysqli, as I am in 8th class, I don't have much time.
<style>.a{float:left;}
</style>
>
in while loop use this
<div class = "a">
<?php <img src='".$row['url']."' width='140' height='140'> ?>
</div>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have this PHP code:
<?php
session_start();
if (!empty($_SESSION['username'])) {
?>
Welcome, <?= $_SESSION['username'] ?>
<br>
<a href='mcLogout.php'>Logout</a>
<?php
} else {
?>
<p class="da">Don't have an account?</p>
<p><a class="lr" href='registrationpage.php'>Register Here</a></p>
<?php
}
?>
The code is display the username of the user who is in the session (logged) and a link to log out. I wish to know how can I give a style to the username using CSS i.e:
"Welcome, <?=$_SESSION['username']?>"
This part of the code.
you could just wrap it in <span> and do some CSS, like:
...
Welcome, <span class="username"><?=$_SESSION['username']?></span>
...
then css:
.username {
color: #D2D8D9;
font-weight: bold;
....
}
what ever comes between wihle echoing are just like any other HTML element.
<h1>" Welcome, " <?= $_SESSION['username'] ?></h1>
or
Welcome, <h1 class="username"><?= $_SESSION['username'] ?></h1>
Just wrap your "Welcome part in a div"
<?php
session_start();
if (!empty($_SESSION['username'])) {
?>
<div class="welcome-user">Welcome, <?= $_SESSION['username'] ?></div>
<br>
<a href='mcLogout.php'>Logout</a>
<?php
} else {
?>
<p class="da">Don't have an account?</p>
<p><a class="lr" href='registrationpage.php'>Register Here</a></p>
<?php
}
?>
You haven't have short tags <? ... ?> Turned on... I think...
Try <?php ... ?> this will do... and instead of <?=$_SESSION['username']; ?> write <?php echo $_SESSION['username']; ?>
This will work...
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
im not familiar with PHP, but I'd like to create in Wordpress something like:
if page id="123"
show this -> <div class"option one">my content</div>
if page id="124"
show this -> <div class"option two">my other content</div>
if page id="125"
show this -> <div class"option three">my other content 2</div>
The code will be placed in my page.php
So what is the exact php code?
for example you have page_id 123, 124 ...etc then
Do it as:
<?php if ( is_page(123) ) {
?>
<div class="option one">my content</div>
<?php } elseif( is_page(124) ) {
?>
<div class="option one">abc content</div>
<?php }
else {
echo '<div class="option one">any content</div>';
}
?>
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
I am working on coding this up with a mixture of PHP and HTML but I can't seem to understand why I am getting an eof yet when I exclude the middle php part, it works just fine. i can't seem to understand why it is giving me an error. I compared it to another part of my program and when I looked at a similar page, it works but this one is simply giving me an unexpected eof
Here is the code. Any suggestions?
<!DOCTYPE html>
<?php
require_once( "data.php" );
error_reporting(0);
?>
<html>
<head>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Course Listings</h1>
</div>
<table class="table">
<?php
foreach( $data as $value )
{
?>
<tr>
<td> <? $value[number] ?> </td>
<td> <? $value[name] ?> </td>
<td> <? $value[instructor] ?> </td>
</tr>
<?
};
?>
</table>
</div>
<script src="http://code.jquery.com/jquery.min.js"></script>
</body>
</html>
The closing bracket of your foreach is not being processed because short tags are disabled. This causes the unexpected eof because php still expects a closing bracket.
Use the standard tag <?php everywhere.
Fred-ii most likely had it right in his comment. if that doesn't completely solve it, replace your <table> contents with this and see if it works. As the other guys mentioned, you may have an issue with <?=
<table class="table">
<?php foreach($data as $value ): ?>
<tr>
<td> <?php echo $value['number']; ?> </td>
<td> <?php echo $value['name']; ?> </td>
<td> <?php echo $value['instructor']; ?></td>
</tr>
<?php endforeach; ?>
</table>