Need a small help in Viewing database content in a webpage - php

I'm trying to view the contents of a database into a webpage. I'm using this code:
<?php
error_reporting(0);
$host="localhost";
$username="root";
$password="";
$database="pncollege";
mysql_connect($host,$username,$password);
#mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM data";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "";
$i=0;
while ($i < $num) {
$email=mysql_result($result,$i,"email");
$name=mysql_result($result,$i,"name");
echo "";
$i++;
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Free Guidance Website Template | Programs :: w3layouts</title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href='http://fonts.googleapis.com/css?family=Montserrat+Alternates' rel='stylesheet' type='text/css'>
<!------ Light Box ------>
<script src="js/jquery.min.js"></script>
<link rel="stylesheet" href="css/swipebox.css">
<script src="js/ios-orientationchange-fix.js"></script>
<script src="js/jquery.swipebox.min.js"></script>
<script type="text/javascript">
jQuery(function($) {
$(".swipebox").swipebox();
});
</script>
<style>
/*
Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.
*/
#media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr { border: 1px solid #ccc; }
td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*
Label the data
*/
td:nth-of-type(1):before { content: "First Name"; }
td:nth-of-type(2):before { content: "Last Name"; }
td:nth-of-type(3):before { content: "Job Title"; }
td:nth-of-type(4):before { content: "Favorite Color"; }
td:nth-of-type(5):before { content: "Wars of Trek?"; }
td:nth-of-type(6):before { content: "Porn Name"; }
td:nth-of-type(7):before { content: "Date of Birth"; }
td:nth-of-type(8):before { content: "Dream Vacation City"; }
td:nth-of-type(9):before { content: "GPA"; }
td:nth-of-type(10):before { content: "Arbitrary Data"; }
}
/* Smartphones (portrait and landscape) ----------- */
#media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
body {
padding: 0;
margin: 0;
width: 320px; }
}
/* iPads (portrait and landscape) ----------- */
#media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
body {
width: 495px;
}
}
* {
margin: 0;
padding: 0;
}
body {
font: 14px/1.4 Georgia, Serif;
}
#page-wrap {
margin: 50px;
}
p {
margin: 20px 0;
}
/*
Generic Styling, for Desktops/Laptops
*/
table {
width: 100%;
border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: left;
}
</style>
<!------ Eng Light Box ------>
</head>
<body>
<div class="header-bg">
<div class="wrap">
<div class="total-box">
<div class="total">
<div class="header_top">
<div class="menu">
<ul>
<li>Home</li>
<li>About</li>
<li>Faculties</li>
<li>Picture Gallery</li>
<li class="active">Principal's Desk</li>
<li>Contact</li>
<div class="clear"></div>
</ul>
</div>
<ul class="follow_icon">
<li><img src="images/fb.png" alt=""></li>
<li><img src="images/tw.png" alt=""></li>
<li><img src="images/rss.png" alt=""></li>
</ul>
<div class="clear"></div>
</div>
<div class="header-bottom">
<div class="logo">
<img src="images/logo.png">
</div>
<div class="logo">
<h1>P.N. College, Parsa</h1>
<h2> ( A constituent unit of Jaiprakash University )</h2>
</div>
<div class="search">
<form>
<input type="text" value="">
<input type="submit" value="">
</form>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
<div class="banner-box">
<div class="wrap">
<div class="main-top">
<div class="main">
<div class="heading3">
<h3 style="text-align:center">Admin Panel</h3>
<hr><br>
</div>
<div class="section group">
<center>
<table>
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo "$userName"; ?></td>
<td><?php echo "$userEmail"; ?></td>
<td><?php echo "$userMsg"; ?></td>
</tr>
</tbody>
</table>
</center>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
<div class="copy-right">
<p style="letter-spacing:4px;border-radius:15px 0 15px 0;background-color:#000;padding-top:15px;padding-bottom:15px;width:100%">© P.N. COLLEGE | DESIGNED BY INCREDIBLE SAURAV</p>
</div>
</body>
</html>
Can anyone help me and guide me where I've made a mistake? I know the code is a little messy and I'm sorry for that. I just can't figure out where I've made a mistake.

Change your loop to fetch an array for each row -
while ($row = mysql_fetch_array($result)) {
$email = $row['email']; // assign this array part to a variable
$name = $row['name'];
echo $name ." " .$email . "<br />"; // echo the variables
}
// now you can close the connection, after you have used the results
mysql_close();
Please, stop using mysql_* functions. They are no longer maintained and are officially deprecated. Learn about prepared statements instead, and consider using PDO, it's not as hard as you think.

Related

How to store the image ID and image of a set of shuffling images in array

I'm a newbie and still learning how to code. So, any help is much appreciated. This is what I have in an
image of what's done so far.
How do I save the selected radio button's image ID and the image itself to my database in PHPMyAdmin? I tried but couldn't figure it out. I would also want to repeat this process three times since the user must select three pictures(1 per submit). Users also should not be allowed to choose the same picture again. Perhaps if a picture is selected, it won't be displayed again in the second and third rounds. Below is my code.
include_once 'database.php';
// Create Level 2 password
if (isset($_POST['submit'])) {
header("LOCATION: registration_l3.php");
try {
$stmt = $conn->prepare("INSERT INTO tbl_pass_level_2(fld_user_id, fld_image_id, fld_image) VALUES(:uid, :iid, :image)");
$stmt->bindParam(':uid', $uid, PDO::PARAM_STR);
$stmt->bindParam(':iid', $iid, PDO::PARAM_STR);
$stmt->bindParam(':image', $image, PDO::PARAM_STR);
$uid = $_POST['uid'];
$iid = $_POST['iid'];
$image = $_POST['image'];
$stmt->execute();
}
catch(PDOException $e)
{
echo "Error: " . $e->getMessage();
}
}
// Auto increment for User ID
$num = $conn->query("SELECT MAX(fld_user_id) AS uid FROM tbl_pass_level_2")->fetch()['uid'];
if ($num){
$num = ltrim($num, 'U')+1;
$num = 'U'.str_pad($num,2,"0",STR_PAD_LEFT);
}
else{
$num = 'U'.str_pad(1,2,"0",STR_PAD_LEFT);
}
$pic = array('1.png','2.png','3.png','4.png','5.png','6.png','7.png','8.png','9.png','10.png','11.png','12.png','13.png','14.png','15.png','16.png','17.png','18.png','19.png','20.png');
shuffle($pic);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Register-Password Level 2</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
body {
background: linear-gradient(to bottom, #ff6699 0%, #ffcc99 100%)fixed;
font: 18px Tahoma, sans-serif;
color: black;
text-align: center;
}
p {font-size: 16px;}
.margin {margin-bottom: 35px;}
.container-fluid {
padding-top: 50px;
padding-bottom: 50px;
}
div {
margin-bottom: 20px;
}
label {
display: inline-block;
width: 100px;
text-align: center;
}
input[type=submit] {
background-color: #ff0066;
border: 2px solid #000000 ;
color: black;
text-decoration: none;
cursor: pointer;
display: inline-block;
width: 120px;
text-align:center;
}
.center {
display: flex;
flex-flow: row wrap;
position: relative;
width: auto;
margin-left: auto;
margin-right: auto;
}
li {
flex: 1 1 16%;
height: auto;
margin: 20px;
margin-right: 40px;
padding: 20px 0;
width: auto;
border: 2px solid #000000 ;
}
.buttonHolder{ text-align: center;}
#footer {
position: relative;
padding: 10px 10px 0px 10px;
bottom: 0;
width: 100%;
/* Height of the footer*/
height: 40px;
}
</style>
</head>
<body>
<div class="container-fluid text-center">
<h2 class="margin"> <b>3 LEVEL PASSWORD AUTHENTICATION <br>SECURITY SYSTEM<b></h2>
<h3 class="margin"><b>LEVEL 2 PASSWORD REGISTRATION </b></h3>
<h4 class="margin">CHOOSE 3 OUT OF 10 DISPLAYED IMAGES </h4>
<label>User ID :</label>
<input name="uid" type="text" id="userid" placeholder="User ID" value="<?php echo $num; ?>"readonly>
<?php
if (isset($_SESSION['error'])) {
echo "<p class='text-danger text-center'>{$_SESSION['error']}</p>";
unset($_SESSION['error']);
}
?>
<form method="post">
<ul>
<div class="center">
<?php
for($i=0;$i<10;$i++)
echo "<li style = \"display:inline-block;\"><input type = \"radio\" name = \"iid\"><img src = \"$pic[$i]\" name=\"image\" width=\"50%\" height=\"150\" class=\"center\" ></li>";
?>
</div>
</ul>
<h4 class="margin text-center"> 1 OUT OF 3 </h4>
<div class="buttonHolder">
<input type="hidden" name="matricnum" value="a174559">
<?php { ?>
<input type="submit" name="submit" value="Submit" align="text-center">
<?php } ?>
</div>
</form>
<!-- Footer -->
<footer class="footer text-center" id=footer>
<p>Copyright � S.SASHNEETA 2022</p>
</footer>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</body>
</html>

Laravel refresh content after auto scroll looping

I want to refresh div content when looping is complete (scroll down and up). Right now im able to looping and refresh page, but the the effect is not smooth. The looping will stop and reset from the begining.
So, can i refresh my page (or if possible only refresh '') everytime 1 full cycle looping is complete?
here's my blade file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="csrf-token" content="{{ csrf_token() }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.datatables.net/r/bs-3.3.5/jq-2.1.4,dt-1.10.8/datatables.min.css" />
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/r/bs-3.3.5/jqc-1.11.3,dt-1.10.8/datatables.min.js"></script>
</head>
<style>
.alert-message {
color: red;
}
.row {
margin-left: -5px;
margin-right: -5px;
}
.columnl {
float: left;
width: 70%;
padding: 5px;
}
.columnr {
float: left;
width: 30%;
padding: 5px;
}
.row::after {
content: "";
clear: both;
display: table;
}
table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
th,
td {
text-align: left;
padding: 16px;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
#header {
width: 100%;
height: 139px;
overflow: hidden;
}
#right_side {
height: auto;
background-repeat: repeat-y;
overflow: hidden;
position: absolute;
font-size: 16px;
}
#content {
height: 460px;
overflow: auto;
}
.inner {
position: relative;
top: 0px;
}
.outer {
overflow: hidden;
}
</style>
<body>
<div class="container">
<div id="header">
<h2 style="margin-top: 12px; text-align: center" class="alert alert-info">LANTAI</h2>
</div>
<div class="row" style="clear: both;margin-top: 18px;">
<div class="row">
<div class="columnl">
<div class="outer">
<div class="inner">
#foreach($poli_doctors as $poli_doctor)
<br>
<h4 class="card-header" style="font-weight:bold; text-align:center;color: blue">
{{$poli_doctor->nmdokter}} {{$poli_doctor->kddokter}}</h4>
<table id="tbl_antrian" class="table table-striped table-bordered">
<thead>
<tr>
<th style="font-weight:bold; font-size: 20px; text-align:center">ID Number
</th>
</tr>
</thead>
<tbody>
#foreach($vw_antrians as $vw_antrian)
#if($vw_antrian['kddokter']==$poli_doctor->kddokter)
<tr id="row_{{$vw_antrian['noantri']}}">
<td style="font-weight:bold; font-size: 20px; width:15%; text-align:center">
{{ $vw_antrian['noantri2'] }}</td>
</tr>
#endif
#endforeach
</tbody>
</table>
#endforeach
</div>
</div>
</div>
<div class="columnr">
<div id="right_side">
<table>
<tr>
<th>Last Scan</th>
</tr>
<tr>
<td>{{$get_lastvalid->noantri2}}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
<script src="{{asset('js/jquery-3.6.0.min.js')}}"></script>
<script>
$(document).ready(function(){
setTimeout(function() {
location.reload();
}, 5000);
$('#tbl_antrian').DataTable();
});
function autoScrollDown(){
$(".inner").css({top:-$(".outer").outerHeight()}) // jump back
.animate({top:0},5000,"linear", autoScrollDown); // and animate
}
function autoScrollUp(){
$(".inner").css({top:0}) // jump back
.animate({top:-$(".outer").outerHeight()},5000,"linear", autoScrollUp)
}
// fix hight of outer:
$('.outer').css({maxHeight: $('.inner').height()});
// duplicate content of inner:
$('.inner').html($('.inner').html() + $('.inner').html());
autoScrollUp();
// location.reload();
</script>
</html>

Sticky footer with include php

<DOCTYPE! html>
<head>
<link rel="stylesheet" type="text/ccs" href="css/indexcss.css">
</head>
<body>
<div id="wrapper">
<div id="header">
<?php
include("utilbar.php");
include("navbar.php");
?>
</div>
<?php
if (isset($_GET["type"])) {
$page = $_GET["type"];
}
else {
$page = "home";
}
//echo "<body onload=\"changeContent('".$page."')\">";
?>
<!--script>
function contentOnload() {
window.location.href('content.php');
}
</script-->
<script>
function navClick(contentName)
{
window.location.href = "index.php?type=" + contentName;
}
</script>
<div class="container">
<?php include($page.".php"); ?>
</div>
<div class="footer">
<?php include("footer.html"); ?>
</div>
</div>
</body>
</html>
CSS here:
html, body {
height: 100%;
margin: 0;
padding: 0;
}
.container {
width: 100%;
margin: auto;
margin-top: 0;
padding: 0;
}
.footer {
bottom: 0;
position: absolute;
}
So I'm trying to get a footer to stick under the content of all my includes, but sometimes it jumps above the content of the included file. I've looked up most possible sticky footer guides and tried to apply them, but none seem to work like they should. I've been trying to fix this for a while now.
Here's the footer HTML CSS:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/footercss.css">
<title>Footer</title>
</head>
<body>
<div id="containerf">
<div id="logos"></div>
<div id="foottext">
<img src="images/youtube.png" height="25" width="25">
<img src="images/twitter.png" height="25" width="25">
<img src="images/fbtrp.png" height="25" width="25">
<b>| Schaafstraat 137 | © 2016 Kopala | All rights reserved.</b>
</div>
</div>
</body>
</html>
#containerf {
width: 100%;
height: 180px;
background-color: #006666;
position: absolute;
bottom: 0;
margin-bottom: 500px;
}
#foottext {
line-height: 180px;
text-align: center;
color: #d9d9d9;
}
#foottext img {
padding-right: 5px;
}
In which file did you set the .footer to bottom:0; ? It seems that you declared it in a regular style.css but in the fotter.htm you include footercss.css
You should paste the bottom:0; to the footercss.css

How to display the full content of a database on clicking on 'Read More' button

I have created a database named Magazine and it has a table social_media. The table has 5 columns namely ID, Headline, Author, Content Short, Content. The Content Short column contains the shorter version of the entire article(which will be displayed in the following code) and the Content column contains the entire article(which will be displayed on clicking the Read More button). I have created a homepage where all the articles from the social_media are displayed in the Content_Left div(NOTE: The Content Short column is displayed and not Content). At the end of each entry from the database there is a 'Read More' button. On clicking on that read more button I want the user to be redirected to a new page 'article.php' where the Headline, Author and Content of the corresponding article will be displayed(The Longer version of the content and not the Content Short). How do I do it? I have created the following webpage:
<?php require_once('connections/connection.php'); ?>
<?php
session_start();
$stmt = $con->query("SELECT * FROM social_media");
?>
<!doctype html>
<html>
<head>
<link href="CSS/Layout.css" rel="stylesheet" type="text/css" />
<link href="CSS/menu.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
<meta charset="utf-8">
<title>Home</title>
</head>
<body style="background-color:#E0DDDD">
<div id="Container">
<div id="Header"></div>
<div id="NavBar">
<nav>
<ul>
<li>Home</li>
<li>Social Media</li>
<li>Tech</li>
<li>Tips & Tricks</li>
</ul>
</nav>
</div>
<div id="Content">
<div id="Content_Left">
<h1><center>Social Media</center></h1>
<table>
<?php
while($records=$stmt->fetch_assoc()) {
$_SESSION["ID"] = $records['ID'];
echo "<tr>";
echo "<th><h3>".$records['Headline']."</h3></th>";
echo "</tr>";
echo "<tr>";
echo "<td>By <strong>".$records['Author']."</strong></td>";
echo "</tr>";
echo "<tr>";
echo "<td>".$records['Content_short']." Read More...</td>";
echo "</tr>";
}
?>
</table>
</div>
<div id="Content_Center">
<h1>Header Here </h1>
<p>Text Goes Here!</p>
</div>
<div id="Content_Right">
<h1>Header Here </h1>
<p>Text Goes Here!</p>
</div>
</div>
<div id="Footer">
<center>Your Copyright Message</center>
</div>
</div>
</body>
</html>
And here is the CSS file(Layout.css):
body{
margin:0;
padding: 0;
}
#Container {
width: 980px;
height:auto;
margin-left:auto;
margin-right:auto;
margin-top:20px;
margin-bottom:21px;
}
#Header {
height:120px;
background-image:url(../Assets/Untitled-1.png);
background-repeat:no-repeat;
margin-bottom:21px;
}
#NavBar {
height:60px;
background-color:#000000;
}
#Content {
background-color:#FFFFFF;
margin-top: 20px;
padding: 5px;
overflow:hidden;
}
#Content_Left {
height: auto;
width: 210px;
padding:5px;
float:left;
background-color: lightblue
}
#Content_Center {
height: auto;
padding:5px;
width: 500px;
float:left;
margin-left: 10px;
margin-right: 10px;
background-color: lightblue
}
#Content_Right {
height: auto;
padding:5px;
width: 210px;
float: right;
background-color: lightblue
}
#Container #Content h1 {
font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
font-style: normal;
font-variant: normal;
font-weight: bolder;
text-shadow: 0px 0px;
}
#Footer {
padding-top: 10px;
height: 100px;
}
And here is the CSS file(menu.css):
nav ul {
margin:0;
padding:0;
}
nav ul li {
list-style-type:none;
display:block;
width:150px;
height:60px;
float:left;
text-align:center;
line-height:55px;
font-family:Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif;
font-size:17px;
}
nav ul li a {
text-decoration:none;
color:#FFF;
}
nav ul li:hover {
background-color:#BBB5B5;
}
nav ul li:hover a {
display:block;
color:Black;
}
I want to display that article in the new page but with the same background theme. Or is there any other way to display the entire article? I hope this much detail is enough. In case any more information is needed please ask.
EDIT: As per the suggestions of the fellow members I have edited the code. My article.php file now looks like this:
<?php require_once('connections/connection.php');?>
<?php
$articleId = $_GET['articleId'];
// you need to fetch only one record this time for showing only the article that wanted to be read. so use `where` condition
$stmt = $con->query("SELECT * FROM social_media WHERE id = $articleId ");
?>
<!doctype html>
<html>
<head>
<link href="CSS/Layout.css" rel="stylesheet" type="text/css" />
<link href="CSS/menu.css" rel="stylesheet" type="text/css" />
<style type="text/css">
</style>
<meta charset="utf-8">
<title>Home</title>
</head>
<body style="background-color:#E0DDDD">
<div id="Container">
<div id="Header"></div>
<div id="NavBar">
<nav>
<ul>
<li>Home</li>
<li>Social Media</li>
<li>Tech</li>
<li>Tips & Tricks</li>
</ul>
</nav>
</div>
<div id="Content">
<div id="Content_Full">
<table>
<?php
while($records=$stmt->fetch_assoc()) {
echo "<tr>";
echo "<th><h1>".$records['Headline']."</h1></th>";
echo "</tr>";
echo "<tr>";
echo "<td>By <strong>".$records['Author']."</strong></td>";
echo "</tr>";
echo "<tr>";
echo "<td>".$records['Content']."</td>";
echo "</tr>";
}
?>
</table>
</div>
</div>
<div id="Footer">
<center>Your Copyright Message</center>
</div>
</div>
</body>
</html>
However, I am getting the following error:
Fatal error: Call to a member function fetch_assoc() on a non-object
How do I resolve this problem?
Change few thing
in php file
echo "<td>".$records['Content_short']." <a href='article.php'>Read More...</a></td>";
to
echo "<td>".$records['Content_short']." <a href='article.php?articleId= " . $records['ID']. "'>Read More...</a></td>";
then in your article.php
<?php
if(isset($_GET['articleId'])){
$articleId = $_GET['articleId'];
}else{
echo "Invalid access"; die;
}
// you need to fetch only one record this time for showing only the article that wanted to be read. so use `where` condition
$stmt = $con->query("SELECT * FROM social_media WHERE id = $articleId ");
Follow same html code of your article listing page on article.php
Change your below line
echo "<td>".$records['Content_short']." <a href='article.php'>Read More...</a></td>";
To:
echo "<td>".$records['Content_short']." Read More...</td>";
Now you've to get details by ID and display data accordingly.

Same css styling is resulting in two different layouts

My partner and I are trying to make a shopping cart site for a school project. We are having trouble with our navbar.
We use the exact same files for styling this specific navbar. (its called universal.css and inherited by each page)
Also, the navbar HTML code is in a PHP file included via script (same script for both).
However, index.php of the products is not vertically aligned with the pull-right statements, though the index.php of the whole website is.
What's the problem?
(The JS file of products and index do not do anything different to the navbar They are essentially the same).
Here is my code, we host at main page https://webdes-nikhilb99.c9users.io/ and products page https://webdes-nikhilb99.c9users.io/products
Mainnav.css
#media (max-width: 1325px) {
.navbar-header {
float: none;
}
.navbar-collapse.collapse.in { display: block!important; }
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.navbar-text {
float: none;
margin: 15px 0;
}
/* since 3.1.0 */
.navbar-collapse.collapse.in {
display: block!important;
}
.collapsing {
overflow: hidden!important;
}
}
.glyphicon-search{
color:white;
}
#search-btn{
background-color: #337ab7;
}
Universal.css
#import url('productModal.css');
#import url('bottomNav.css');
#import url('mainNav.css');
row-title{
color:#337ab7;
font-weight:bold;
font-size:30pt;
margin-top:60px;
width:100%;
padding-bottom:50px;
}
#content-wrapper{
background-color: black;
width:100%;
opacity: 0.9;
}
#content-wrapper .content p{
color:white;
}
.content{
color:#337ab7;
font-weight:bold;
font-size:20pt;
text-align:center;
}
.content p{
font-size:10pt;
}
#mainNav{
background-color: black;
font-family: Montserrat;
font-weight: 700;
font-size:10pt;
border-bottom: 4px solid #337ab7;
background: rgba(0,0,0,0.9);
}
#img1{
position:absolute;
top:0;
left:0;
width:100%;
}
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset !important;
}
.navbar-custom .navbar-toggle .icon-container .icon-bar {
background-color: #000;
}
.navbar-custom .navbar-toggle .icon-container{
background-color:#000;
}
.navbar-nav .dropdown a{
color:#337ab7;
font-size:18pt;
text-decoration:none;
}
.blacktext{
color:#337ab7;
font-size:18pt;
}
/*Drop down menu*/
.dropdown:hover .dropdown-menu {
display: block;
}
.dropdown-menu{
/**Change up the stuff in the dropdown here*/
}
.dropdown{
line-height:95px;
}
.navbar-nav .dropdown .dropdown-toggle{
font-size:30pt;
}
.navbar-nav > li >a{
line-height:65px ;
}
.navitem{
font-size:30pt;
}
.navbar-nav > li >a:focus{
background-color:transparent;
}
#loginWindow .modal-dialog .modal-footer{
text-align: left !important;
}
body{
padding-top: 65px;
}
.icon-bar{
background-color: #fff;
line-height:65px;
font-size:30pt;
}
.vertical-center {
min-height: 100%; /* Fallback for browsers do NOT support vh unit */
min-height: 100vh; /* These two lines are counted as one */
display: flex;
align-items: center;
}
body{
background-color: black;
}
/*.btn-success{
background-color: #337ab7;
}
.btn-success:hover{
background-color:blue;
}*/
/*Login and Registration buttons*/
.btn-primary{
background-color:#337ab7;
}
.btn-primary:focus{
background-color:#337ab7;
}
.btn-primary:hover{
background-color:white;
color:#337ab7;
}
.navbar-nav > li >a:hover{
background-color:transparent;
color:white;
}
#logo{
margin-left:10px;
margin-top:10px;
margin-right:20px;
margin-bottom:3px;
}
#nikhil{
color:white;
}
#yadu{
color:white;
}
#content-wrapper{
position:absolute;
left:10%;
width:80% !important;
margin-top: 50px;
border-radius:25px;
opacity:0.95;
border: 3px double white;
}
.active a{
color:white !important;
}
.active a:hover{
color:white !important;
}
.active a:focus{
color:white !important;
}
body{
background-image:url("http://www.legionreport.com/wp-content/uploads/2014/04/blakegriffindunk.jpg");
}
#mtt{
color:#337ab7;
}
#bballfam{
height:200px;
width:80%;
}
Products page:
<html>
<head>
<title>Products</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="/favicon.ico">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" type="text/css">
<link href='//fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/css/products.css">
</head>
<body>
<div class="container">
<?php
include('../snips/loginModal.php');
include('../snips/registrationModal.php');
include('../snips/menuMain.php');
?>
<div id='content-wrapper'>
<div class="row">
<div class="col-md-4 info basketball-info">
<h2 class="title text-center">Basketball</h2>
<div class="apparel">
</div>
<div class="balls">
</div>
<div class="footwear">
</div>
<div class="gear">
</div>
</div>
<div class="col-md-4 info football-info">
<h2 class="title text-center">Football</h2>
<div class="apparel">
</div>
<div class="balls">
</div>
<div class="footwear">
</div>
<div class="gear">
</div>
</div>
<div class="col-md-4 info soccer-info">
<h2 class="title text-center">Soccer</h2>
<div class="apparel">
</div>
<div class="balls">
</div>
<div class="footwear">
</div>
<div class="gear">
</div>
</div>
</div>
<script type="text/javascript">
$("#srch-term").css('width', $(window).width()).css('right','-9%');
$(".bottom-nav").css('display','none');
</script>
<!--<div class="row">
<div id='basketball-info' class="info col-md-12">
<h2 class="title text-center">Basketball</h2>
<div class="apparel">
</div>
<div class="balls">
</div>
<div class="footwear">
</div>
<div class="gear">
</div>
<!--Alphabetical order
</div>
</div>
<div class="row">
<div id='football-info' class="info col-md-12">
<h2 class="title text-center">Football</h2>
<div class="apparel">
</div>
<div class="balls">
</div>
<div class="footwear">
</div>
<div class="gear">
</div>
<!--Alphabetical order
</div>
</div>
<div class="row">
<div id='soccer-info' class="info col-md-12">
<h2 class="title text-center">Soccer</h2>
<div class="apparel">
</div>
<div class="balls">
</div>
<div class="footwear">
</div>
<div class="gear">
</div>
<!--Alphabetical order
</div> -->
</div>
</div>
</div>
<?php
include('/home/ubuntu/workspace/snips/bottomNav.php');
?>
<?php
include('/home/ubuntu/workspace/snips/productPageModal.php');
?>
<script src="/js/products.js"></script>
<script type="text/javascript">
// $(".title").click(function(){
// $("#productsPage .modal-title").text($(this).text());
// });
// $(".bottom-nav").css('left','0');
</script>
</body>
</html>
Main Page:
<!DOCTYPE HTML>
<html>
<head>
<title>Baller Sporting Goods</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/index.css">
<link href='//fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="/js/index.js" type="text/javascript"></script>
<body>
<?php
/*Login page is a Bootstrap modal included on the main page. See snips/loginModal.php*/
include('snips/loginModal.php');
/*Registration page is a Bootstrap modal included on the main page. See snips/registrationModal.php*/
include('snips/registrationModal.php');
include('snips/menuMain.php')
?>
<div class="container" id="wrapper">
<div id='content-wrapper'>
<div class="row">
<h2 class="text-center row-title" id='mtt'>
<img class='center-block' id = "welcome" src="img/welcome.png" width="80%"/>
<br>
<i>Where Ball Really Is Life</i>
<br>
<br>
</h2>
<div class="col-md-9 content center-block">
Online Services
<p>
At Baller Sporting Goods, we offer a variety of services available to many devices.
On our site, you may use our always available quick-search that will locate the exact item
you need in a matter of seconds.
Or, if you like to shop around yourself, you can look over our exhorbitant list of products
on our site by clicking on the <a href='/products/'>Sports</a> icon on the top. We implement
an organized structure of products that sort by sport, company, and type of equipment. Check
it out!
</p>
</div>
<div class="col-md-9 content center-block">
Our Products
<p>
We started in 1991 in the garage of two partners: Nikhil Bharani & Yadunandan Pillai.
Both were high school students tired of studying; so they decided to take the easy way
out and start a business.
They accepted a small loan of one million dollars, which they used on buying the necessities
of a business: products. Eventually, the garage was full of brand new products from medium-scale
companies like ESPN and Dicks Sporting Goods, which they sold for 50 cents on EBay.
</p>
<p>
However, one million dollars is quite a small amount, so they ran out quicker than they planned.
The two collaborators then decided to escape loan sharks by moving to an island outisde US jurisdiction
and starting a shady business.
This business, today, is the most legit one in the world: Baller Sporting Goods.
We sell numerous performance-enhancing drugs and other nutritional supplements along with
imported goods from richer companies like Hong Kong.
We also sell purposefully torn up clothing made by hand.
Our best products are the cubic soccer balls.
</p>
</div>
<br>
</div>
<?php
include('snips/bottomNav.php');
?>
</div>
<!--<script src="/js/libs/slideshow.js"></script>-->
<script src="/js/index.js"></script>
</body>
</html>
Index.css
#import url('universal.css');
#searchbar{
margin-right:auto;
margin-left:auto;
width:50%;
}
#media screen and (min-width: 1200px){
.content{
left:12.5%;
}
}
.content{
padding-bottom: 50px;
}
#media screen and (max-width:800px){
#content-wrapper{
padding-right:40px;
padding-left:40px;
}
}
#wrapper{
width:100%;
height:100%;
}
#searchbar #searchForm{
color:blue;
margin-left: auto;
margin-right:auto;
}
#title h2{
font-family: Montserrat;
font-weight: bold;
color:black;
text-align:center;
margin-top:65px;
}
#searchbar #searchForm input[name='search']{
background-color:#e9e9e9;
}
#slideshoww{
margin-top:70px;
margin-right:auto;
margin-left: auto;
position:absolute;
width:100%;
opacity:0.3;
}
#searchbar #searchForm #bar_img{
font-size:25pt;
}
#welcome{
width:95%;
}
#bar_img{
color:black;
}
#content-wrapper .row-title i{
font-size:20pt;
color:lightGrey;
}
#content-wrapper{
position:absolute;
left:10%;
width:80% !important;
margin-top: 100px;
border-radius:25px;
opacity:0.90;
border-right: 3px double white;
border-left: 3px double white;
font-family:Montserrat;
}
.col-md-6{
left:25%;
}
Products.css
#import url('universal.css');
#media screen and (min-width:990px){
.col-md-4{
border-right: 4px solid #337ab7;
}
.col-md-4:last-child{
border:none;
}
}
.col-md-4{
text-align:center;
font-family: Montserrat;
}
.col-md-4 .main-link{
font-size:20pt;
color:white;
font-weight:bold;
}
.info .title{
font-size:20pt;
color:#337ab7;
font-weight:bold;
}
#content-wrapper{
background:rgba(0,0,0,0.9);
}

Categories