Display specifics columns of each rows in html - php

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

Related

How to move articles to the beginning of the first page after the category is chosen

I´m making a site for myself and I´ve been stuck with this issue. The site has several categories, for example geometry -> triangles. When I'm scrolling through articles and do not have a filtered category on yet, everything is ok. But when I filter categories and choose a specific one, for example triangles, all other articles that do not concern triangles get hidden. But that's not the issue. The problem is, if the articles for triangles where on the page 3 while the filter was off and you could see all the articles all together, then even after the filter is on the chosen category will be left on the page 3 and won't move to the first page. How do I fix this?
bodyOfmainPage.php
<main class="index-main">
<section class="articles">
<div class="article_content container container--pall">
<h1 class="heading">მთავარი გვერდი</h1>
<div class="article_grid">
<?php $idM=get_size(); ?>// number of articles
<?php for($id=$idM;$id>0;$id--): ?>
<?php $idN= get_num_size($id);?>
<div class="article_item" href="#" data-id ="<?= intval(($idM - $id)/4 + 1) ?>" data-category="<?= get_data_category($id) ?>">
<div class="article_image" style="background-image: url('<?= get_img_url($id) ?>')"> </div>
<div class="article-text">
<div class="article_date"><?= get_article_date($id) ?></div>
<div class="article_title"><?= get_article_title($id) ?></div>
<div class="article_description"><?= get_article_description($id) ?></div>
<div class="hashtag"><?= get_hashtag($id) ?></div>
<div class="butt">
<a class="AB" href="<?= get_article_link($id) ?>">
<button type="button" class="clickA" >გადასვლა</button></a>
</div>
</div>
</div>
<?php endfor; ?>
</div>
</div>
</section>
<div class="num">
<ul class="contentNum">
<li class="navigation" data-id ="1">1</li>
<li class="navigation" data-id ="2">2</li>
<li class="navigation" data-id ="3">3</li>
<li class="navigation" data-id ="4">4</li>
<li class="navigation" data-id ="5">5</li>
</ul>
</div>
</main>

Why did laravel wrap my sidebar in an em tag?

**Using Laravel 5.8.31 & Bootstrap 4. Browser: Chrome v. 76.0.3 and Opera 62.0.33 **
I was testing my CRUD functions by deleting a post. After deletion, the controller redirects back to my post index page. When the page loaded, the bootstrap side bar wrapped down below the other posts, rather than being on the right. Was fine before the post deletion.
I tried altering the cols and floating elements to no avail. Using Chrome dev tools, I see that the sidebar is nested in an em tag that isn't in the code. Tried clearing application cache. No effect.
I suspect this has something to do with the blade templating language and parsing the html, although if it is, I have no idea how to fix this other than manually installing the sidebar on every page.
How do I fix this??
Code can be found here: https://github.com/gkennedy87/Hillcrest/tree/master/resources/views
(It seems that laravel is also wrapping the footer in an em tag. Although this is a non-issue at the moment)
// views/posts/index.blade.php
#extends('layouts.app')
#section('content')
#include('inc.navbar')
<div class="container">
<div class="row">
<div class="col-md-8 col-lg-8">
<h1>Our Blog</h1>
#if (count($posts) > 0)
#foreach ($posts as $post)
<div class="card mb-4">
<img class="card-img-top" src="http://placehold.it/750x300" alt="Card image cap">
<div class="card-body">
<h2 class="card-title">{{$post->title}}</h2>
<p class="card-text">{!! str_limit($post->body,200,'...')!!}</p>
Read More →
</div>
<div class="card-footer text-muted">
Posted on {{$post->created_at}} by
Start Bootstrap
</div>
</div>
#endforeach
{{$posts->links()}}
#else
<p>No Posts Found</p>
#endif
</div>
#include('inc.sidebar')
<!--end row -->
</div>
<!--end container -->
</div>
#include('inc.footer')
#endsection
// views/inc/sidebar.blade.php
<!--sidebar start -->
<div class="col-md-4 col-lg-4">
<div class="sticky">
<!-- Search Widget -->
<div class="card my-4">
<h5 class="card-header">Search</h5>
<div class="card-body">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Go!</button>
</span>
</div>
</div>
</div>
<!-- Categories Widget -->
<div class="card my-4">
<h5 class="card-header">Categories</h5>
<div class="card-body">
<div class="row">
<div class="col-lg-6">
<ul class="list-unstyled mb-0">
<li>
Web Design
</li>
<li>
HTML
</li>
<li>
Freebies
</li>
</ul>
</div>
<div class="col-lg-6">
<ul class="list-unstyled mb-0">
<li>
JavaScript
</li>
<li>
CSS
</li>
<li>
Tutorials
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Side Widget -->
<div class="card my-4">
<h5 class="card-header">Side Widget</h5>
<div class="card-body">
You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!
</div>
</div>
</div>
</div>
<!-- sidebar end -->
I setup the app on a local environment, the sidebar always stays on the right even after deleting a post. The response also doesn't contain any em tags. Could you try clearing the cache:
php artisan cache:clear
php artisan view:clear
php artisan config:clear

Inheriting files in specific div through php files

I've created a file called menu.php to be my universal nav/menu file. The way it was created using bootstrap though, I have a div called article at the bottom which serves as the main body of the app, since the sidebar in my menu is expandable/responsive.
I really want to have one global menu file. I'm currently including it in all of my content pages like so:
<?php include("menu.php")?>
This works but it breaks my formatting. What I'm trying to do is make all of my main pages such as index.php have the html formatted so that it will always sit inside the tag in my code below which shows card classes.
<header>
<div class="branding">
<div class="menu-button menu-toggle nav">
<i class="material-icons">menu</i>
</div>
<img src="" />
</div>
<div class="page-details">
</div>
<div class="settings">
<div class="menu-button profile">
<i class="far fa-user-circle fa-2x"></i>
</div>
<div class="menu-button menu-toggle aside">
<i class="material-icons">chat</i>
</div>
</div>
</header>
<div class="app">
<nav>
<div class="title-block">
<img src="" />
</div>
<ul>
<li><a href="#"><i class="material-icons">home</i>
<span>Home</span></a></li>
</ul>
</nav>
<!--This following article section is the main body of the page, that I want each additional page to take up-->
<article>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</article>
</div>
Example:
Menu.php is my global menu/nav file but it makes the page/app act as a wrapper for all the other pages (index.php, editor.php, etc.)
menu.php
<div class="app">
<nav>
Nav menu content
</nav>
<article>
This will be the main page article for index.php, editor.php,etc.
</article>
</div>
example with index.php (the start and end are just hypothetical to show the endpoints)
<body>
<?php include("menu.php");?>
<?php start('article') ?>
<!--Everything from here to the end() call would be inserted in the article tags on menu.php-->
<div class="app">
<div id="content">
<div>
<h1 style="text-align: center; color: #A9BD50; ">Content Management Editor</h1>
</div>
<form method="post">
<textarea id="mytextarea"></textarea>
</form>
<div>
<h1 style="text-align: center; color: #A9BD50; ">Preview</h1>
</div>
</div>
</div>
<?php end() ?>
</body>

Where can I find the file PHP is fetching text/table from?

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>

Applying PHP inside multiple divs

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}}?>

Categories