I've made a section in HTML, but I want to be visible only to people who are if($Admin >= 1) from my database.
But I don't know how to write it.
This is my HTML so far.
!-- ADM SECTION -->
<div class="backimg" id="section-10">
<div class="bghover wow fadeInUp" data-wow-duration="1.5s" data-wow-delay=".5s">
<div class="grid flex16">
<div class="row paddtop5">
<h3 class="paraw wow fadeInUpBig" data-wow-duration="2s" data-wow-delay=".5s">ADMIN SECTION</h3>
<div class="admin">
<h3 data-wow-duration="2s" data-wow-delay=".5s"> Alege opțiunea </h3>
</div>
<!-- ban -->
<style>
ul.b {list-style-type: square;}</style>
<div class="ban">
<ul class="b">
<li>BAN SYSTEM</li>
<br>
<li>KICK SYSTEM</li>
<br>
<li>ADMIN JAIL SYSTEM</li>
<br>
</ul>
</div>
<div class="ban2">
<ul class="b">
<li>SEARCH SYSTEM</li>
<br>
<li>LOG SYSTEM</li>
<br>
<li>AWARD SYSTEM</li>
<br>
</ul>
</div>
<div class="ban3">
<ul class="b">
<li>MANAGAMENT SYSTEM</li>
<br>
<li>UNBAN SYSTEM</li>
<br>
<li>UNJAIL SYSTEM</li>
<br>
</ul>
</div>
Shall I add if($Admin >= 1) echo ? I want to show nothing to who has $admin lower than 1. And who has higher or equal than 1, to show that HTML part.
<?php if($Admin >= 1) { ?>
<!-- ADM SECTION -->
<div class="backimg" id="section-10">
<div class="bghover wow fadeInUp" data-wow-duration="1.5s" data-wow-delay=".5s">
<div class="grid flex16">
<div class="row paddtop5">
<h3 class="paraw wow fadeInUpBig" data-wow-duration="2s" data-wow-delay=".5s">ADMIN SECTION</h3>
<div class="admin">
<h3 data-wow-duration="2s" data-wow-delay=".5s"> Alege opțiunea </h3>
</div>
<!-- ban -->
<style>
ul.b {list-style-type: square;}</style>
<div class="ban">
<ul class="b">
<li>BAN SYSTEM</li>
<br>
<li>KICK SYSTEM</li>
<br>
<li>ADMIN JAIL SYSTEM</li>
<br>
</ul>
</div>
<div class="ban2">
<ul class="b">
<li>SEARCH SYSTEM</li>
<br>
<li>LOG SYSTEM</li>
<br>
<li>AWARD SYSTEM</li>
<br>
</ul>
</div>
<div class="ban3">
<ul class="b">
<li>MANAGAMENT SYSTEM</li>
<br>
<li>UNBAN SYSTEM</li>
<br>
<li>UNJAIL SYSTEM</li>
<br>
</ul>
</div>
<?php } ?>
You can make use of SESSION variables in php. You can check for that value and put a if statement.
Where Admin will be one of the attributes for user in your user table.
If truthy show your html section.
if (isset($_SESSION['Admin'])) {
// show your content
}
Checking for Admin level:
if ($_SESSION['Admin'] >= 1) {
// show your content
}
You can use if else in html like so
<?php if ($Admin === 1) : ?>
<h1> show admin html </h1>
<?php else if ($Admin < 1) : ?>
<h1> do smth else </h1>
<?php else : ?>
<h1> do thmth else </h1>
<?php endif : ?>
In your html file, you can write down like this ,
<?php if ( $admin>=1 ): ?>
<div>
Here you can put all of your html
code for admin.
</div>
<?php endif;?>
A Lot of imporoments have to be done for the coding. Follow following steps.
Create a PHP file ex:index.php
Add all your HTML code within that PHP file.
Write following code for display this section.
Procedure 1.
<?php
if($Admin > 1) {
?>
//write your html code here.
<?php
}
?>
Related
I have been working on a job-listing website during the last few weeks as a self taught CS student. I finished the front end of the website in July and now I am learning mySQL and PHP to produce the back-end.
So, on the current "job listing" page search.html, there is currently 4 listing in the page but I typed those directly on the html when I was making the front-end just to see how it will look like.
I have build my database like this and added few examples:
I also made a back-end page to let the user add a a new listing and it is working.
I am not sure it was a good idea to start with the front-end. I am now trying to display three columns (title, location, type) of eachrowbased on my specific front-end layout. I won't display thedate` yet since I have not created it on mySQL.
search.html
<div class="job-listing">
<div class="container">
<div class="job-number">
<h2>We Found <span id="number-jobs-total" class="text-secondary"></span> Offers For <span>You</span> </h2>
</div>
<ul class="job-board">
<li class="job job-1">
<div class="job-title">
<h2>Process Engineer</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Full-Time</p>
</div>
<div class="job-date">
<p>Published on 07/19/2019</p>
</div>
<div class="job-industry">
<p>Engineering</p>
</div>
<ul class="job-keywords">
<li>Engineering</li>
<li>Science</li>
</ul>
</li>
<li class="job job-2">
<div class="job-title">
<h2>Chief Financial Officier</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Full-Time</p>
</div>
<div class="job-date">
<p>Published on 07/18/2019</p>
</div>
</li>
<li class="job job-3">
<div class="job-title">
<h2>Assistant CEO</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Part-Time</p>
</div>
<div class="job-date">
<p>Published on 07/18/2019</p>
</div>
</li>
<li class="job job-4">
<div class="job-title">
<h2>Front-End Developer</h2>
</div>
<div class="job-location">
<p>Location: Naypyitaw</p>
</div>
<div class="job-type">
<p>Type: Part-Time</p>
</div>
<div class="job-date">
<p>Published on 07/18/2019</p>
</div>
</li>
</ul>
<nav class="pagination-container">
<ul class="pagination">
<li>Previous</li>
<li>Next</li>
</ul>
</nav>
</div>
</div>
Things I will do later:
I need to protect my PHP code against injections
The pagination button is not working
I am currently displaying content from my database using a foreach loop within a boostrap panel. However the layout is not behaving as I expected it too, I have tried resolving this using breaks which had fixed the layout from being worse than it is at the present. However it is still off if you take a look at the image below :-
In addition to this I also have bootstrap dropdown menu's that are not working at all embedded within a div.
This is my code -
<div class="parabox">
<!-- Collect the nav links, forms, and other content for toggling -->
<!-- Search -->
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search For Comics">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<strong><p class="navbar-text">Sort Comics By : </p></strong>
<ul class="nav navbar-nav">
<li class="dropdown">
Order Comics<span class="caret"></span>
<ul class="dropdown-menu">
<li>Ascending Order</li>
<li>Descending Order</li>
<li>Numerical Order</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
Universe<span class="caret"></span>
<ul class="dropdown-menu">
<li>Dark Horse Comics</li>
<li>DC</li>
<li>IDW</li>
<li>Image</li>
<li>Marvel</li>
<li>Valiant</li>
</li>
</ul>
</div>
</div>
</br>
<!-- Start of Col Div -->
<div class="col-md-12">
<!--/.Panel for Comics -->
<!-- Count for Comics -->
<?php
if(count($comics)){
?>
</br>
<div class="panel panel-default">
<div class="panel-heading panel-heading-green">
<h3 class="panel-title">My Comics</h3>
</div>
<div class="panel-body">
<div class="row">
<!--/.row1 -->
<!-- Display each comic by id -->
<?php foreach($comics as $list): ?>
</br>
<div class="col-md-3 comic">
<a href="#">
<?= ($list['image'] <> " " ? "<img style='max-width:200px; max-height:250px;' src='Images/{$list['image']}'/>" : "") ?>
</a>
<div class="comic-title">
<?= ($list['name'] <> "" ? $list['name'] : "") ?> #<?= ($list['issue'] <> "" ? $list['issue'] : "") ?>
</div>
<div class="comic-add">
</div>
</div>
<!-- End of Foreach Statement for Comics -->
<?php endforeach; ?>
<!-- Else show this message if user has no entries -->
<?php
}else {
?>
<p><b>You haven't posted any comic yet!</b></p>
<?php } ?>
</div>
</div>
</div>
<!--/.row1-collapse -->
</div>
<!-- /.container -->
</div>
I am using MVC format which is why the code may seem short or missing pieces which is in header and footers within my template part of my application. Any ideas on what I can do to sort the layout out and get the dropdown menu's to work as they do seem a little related ?
As far as I know, bootstrap requires you to always have a markup like:
<div class="container">
<div class="row">
<div class="col-*">…</div>
<!-- many more cols -->
</div>
</div>
So this:
container
row
col
col
col
row
…
structure should always be give, whereby this structure can be nested.
This way the layout has all the negative margin magic applied
UPDATE
According to the posted image I guess that the resulting markup is corrupted (if the »container > row > col« structure exists). I recommend to have a a look at the browser console and compare the resulting dom tree with the expected. It is also very helpful to search the page source, in Firefox corrupted elements (missing closing tag, wrong attributes etc) are shown in red, so this helps to find the bug.
*Create a wrapper div to hold the image, title etc. Then for that div add a css with the style as display:inline-block; So if it is not able to accomodate with in the view in browser, it will get automatically wrapped into the next line. Follow this example see teh working sample code created by some one: http://jsfiddle.net/ajruk60t/3/*
You must break your line after the number of columns your row can contain. For instance, if you use col-3, then you must not define more than 4 columns. At this point, you recreate a row and carry on.
<div class="row">
<?php
$i = 1;
foreach($comics as $list) { ?>
<div class="col-md-3">
...
</div>
<?php
if ($i % 4 == 0) {
?></div><div class="row"><?php
}
$i++;
?>
<?php } ?>
</div>
Alternatively, you can create the same effect adding manual breakpoints rather than recreating a row. I have not tried this solution myself, but read it here:
<div class="clearfix visible-md-block"></div>
Thank you for your help it steered me to the answer which was the foreach loop had to start after the break.
<?php require('template/header.phtml') ?>
<div class="container">
<div class="row">
<!-- Start of Col Div -->
<div class="col-md-12">
<!--/.Panel for Comics -->
<!-- Count for Comics -->
<?php
if(count($comics)){
?>
</br>
<div class="panel panel-default">
<div class="panel-heading panel-heading-green"><h3 class="panel-title">My Comics</h3></div><!-- End of Panel Heading -->
<div class="panel-body">
<div class="row">
<!--/.row1 -->
<!-- Display each comic by id -->
</br> <?php foreach($comics as $list): ?>
<div class="col-md-3 comic">
<a href="#">
<?= ($list['image'] <> " " ? "<img style='max-width:200px; max-height:250px;' src='Images/{$list['image']}'/>" : "") ?>
</a>
<div class="comic-title">
<?= ($list['name'] <> "" ? $list['name'] : "") ?> #<?= ($list['issue'] <> "" ? $list['issue'] : "") ?>
</div>
<div class="comic-add">
</div>
</div> <!-- End of Col-MD-3 Comic -->
<!-- End of Foreach Statement for Comics -->
<?php endforeach; ?>
<!-- Else show this message if user has no entries -->
<?php
}else {
?>
<p><b>You haven't posted any comic yet!</b></p>
<?php } ?>
</div><!-- end of row -->
</div> <!-- end of panel body -->
</div> <!-- end of panel panel-default -->
<!--/.row1-collapse -->
</div> <!-- end of col-md-12 -->
</div> <!-- End of Row -->
</div> <!-- /.container -->
<?php require('template/footer.phtml') ?>
I recently inherited a website with a horrible file structure. I need to update some content (text) but I can’t find where it is being defined. The database table does not have the information, so I'm guessing the text is being defined elsewhere. Is there a tool or "trick" in Chrome Dev Tools to find the content source? Your help is much appreciated!
***Snippet from PHP File:
<div id="product_wrapper" class="add-bottom30">
<div class="columns sixteen">
<div class="columns twelve add-bottom60 catalogue">
<!-- Pager -->
<?php include('sql-' . $_SESSION['lang'] . '/promos.php');?>
</div>
<div class="columns four side">
<h5 style="margin-bottom:25px;">FLYERS</h5>
<ul>
<li style="background-color:#0065a4;">
<?php echo flyer_jet_2016; (where the text I need to change lives) ?>
</li>
</ul>
</div>
<div class="clear"><!-- ClearFix --></div>
</div>
</div>
*** Snippet from source code ("View Source" in Chrome):
<div class="columns four side">
<h5 style="margin-bottom:25px;">FLYERS</h5>
<ul>
<li style="background-color:#0065a4;">
<span class="icon" data-icon="(" style="color:#fff;margin-bottom:15px;"></span><br>Tool Storage<br>Solutions 2016
</li>
</ul>
</div>
<div class="clear"><!-- ClearFix --></div>
</div>
How I do following Code in angular JS
// PHP Code
<?php foreach($data as $key=>$row) {
if($key%2 == 0) { ?>
<div class="col 3"> Run this
<ul>
<?php } ?>
<li> Some Data </li>
<?php if($key%2 == 1) { ?>
</ul></div>
<?php } } ?>
I want to run above code in angular JS. any help appreciated.
Like this
<div ng-repeat="key in data">
<div ng-if="(key%2 == 0)" class="col 3"> Run this
<ul>
<li> Some Data </li>
</ul>
</div>
<div ng-if="(key%2 == 1)"> Run this
<ul>
<li> Some Data </li>
</ul>
</div>
</div>
well, I have been trying to implement my PHP inside multiple divs but somehow my CSS gets messed up and the records start to display diagonally i.e first record displays correctly and then the rest of the records starts displaying from the end of their previous record (that can be viewed when scrolling right). Which is very annoying. What I'm trying to achieve is: To position my divs OR PHP in such a way that my CSS does not get disturbed, is this possible? Here's my PHP code for the particular data, any help would be appreciated.
<?php
$result1 = mysql_query("SELECT *from `movie_schedule`");
if(mysql_num_rows($result1))
{while($row2 = mysql_fetch_array($result1, MYSQL_BOTH))
{
?>
<div id="event" class="content-event">
<!-- container -->
<div class="container">
<h3>Show Times</h3>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div class="pic"> </div>
<ul>
<li class="hedding"><?php print($row2['Movie_ID']); ?> <?php print($row2['Movie_Name']); ?></li>
<li class="date"><?php print($row2['Movie_Date']); ?></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br><?php print($row2['Show_Time']); ?></p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text"><?php print($row2['Movie_Cost']); ?></p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num"><?php print($row2['Movie_ID']); ?></li>
<li class="button yellow">Remove</li>
</ul><br><br>
<?php
}}
?>
</div>
</div>
</div>
It's not the CSS that's messing up. You're ending your loop before you close all of your elements properly inside a single block. You open the loop with a div, and you end it with an ul.
You can actually view the nested elements using a page inspector. In Chrome or Firefox, for example, this is achieved by right-clicking the page and selecting "Page inspector".
Try closing all your elements properly before closing your loop.
You are messing up with closing </div>
<?php
$result1 = mysql_query("SELECT *from `movie_schedule`");
if(mysql_num_rows($result1))
{
while($row2 = mysql_fetch_array($result1, MYSQL_BOTH))
{?>
<div id="event" class="content-event">
<div class="container">
<h3>Show Times</h3>
<div class="event-grids">
<div class="col-md-3 event-grid">
<div class="pic"> </div>
<ul>
<li class="hedding"><?php print($row2['Movie_ID']); ?> <?php print($row2['Movie_Name']); ?></li>
<li class="date"><?php print($row2['Movie_Date']); ?></li>
</ul>
<div class="clearfix"> </div>
</div>
<div class="col-md-4 event-grid small-text">
<p><br><?php print($row2['Show_Time']); ?></p>
</div>
<div class="col-md-2 event-grid large-text">
<p class="text"><?php print($row2['Movie_Cost']); ?></p>
</div>
<div class="col-md-3 event-grid text-button">
<ul>
<li class="num"><?php print($row2['Movie_ID']); ?></li>
<li class="button yellow">Remove</li>
</ul>
<br><br>
</div>
</div>
</div>
</div>
<?php}}?>