How to fix "Parse error: syntax error, unexpected ':'"? [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I don't see any error on line 190: $query = “https://www.googleapis.com/youtube/v3/search?part=snippet&q=$search&maxResults=$per_page&videoCategoryId=$category&safesearch=strict&key=$apikey”;
<?php
error_reporting(1);
$movie = $_GET[movie];
$tmdb_api_key = '9366d6385a1a15cab92bdde8de2b98af'; // change it with your themoviedb.com API
$aff_link = 'http://google.com'; // your offer link
$image_host = 'http://image.tmdb.org/t/p/';
$json_tmdb = 'http://api.themoviedb.org/3/movie/'.$movie.'?api_key='.$tmdb_api_key.'&append_to_response=credits,images,trailers,keywords,releases,similar_movies';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $json_tmdb);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
if ($data->title == null) {
die;
}
$backdrop_to_background = $backdrop_to_player = 0;
$backdrops = count($data->images->backdrops);
if ($backdrops > 1) {
$backdrop_to_player = rand(0, $backdrops-1);
$backdrop_to_background = $backdrop_to_player;
while ($backdrop_to_background == $backdrop_to_player) {
$backdrop_to_background = rand(0, $backdrops-1);
}
}
$movie_title = $data->title;
$movie_runtime = $data->runtime;
$n = count($data->genres);
$i = 0;
$movie_genres = '';
while ($i <= $n-1) {
$movie_genres .= $data->genres[$i]->name;
if ($i < $n-1) {
$movie_genres .= ', ';
}
$i++;
}
$n = count($data->credits->cast);
$i = 0;
$movie_cast = '';
while ($i <= $n-1) {
$movie_cast .= $data->credits->cast[$i]->name . ' (' . $data->credits->cast[$i]->character . ')';
if ($i < $n-1) {
$movie_cast .= ', ';
}
$i++;
}
$movie_plot = $data->overview;
$movie_poster = $image_host.'w185'.$data->poster_path;
$movie_player = $image_host.'w780'.$data->images->backdrops[$backdrop_to_player]->file_path;
$movie_background = $image_host.'w780'.$data->images->backdrops[$backdrop_to_background]->file_path;
?>
<html>
<head>
<title>Watch <?php echo $movie_title;?> Full Movie</title>
<link href="img/favicon.ico" rel="shortcut icon">
<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Cabin" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
$("#player-play").click(
function(){
$("#player-container").attr("style","background: url(img/stripes.png); background-repeat : repeat; z-index: 1; width: 854px; height: 480px; margin: 100px auto; position: absolute; top:0; left:0; bottom:0; right:0; z-index: 1; opacity: 0.9; filter:alpha(opacity=90); border: 20px solid rgba(255, 0, 0, 0.3);");
$("#player-play").addClass("player-hidden");
$("#player-error").removeClass("player-hidden")
}
)
}
)
</script>
<style>
body {
margin : 0px 0px 0px 0px;
background-color: #060606;
}
.player-play {
width: 854px;
height: 480px;
background: url(img/inactive-button.png) no-repeat;
background-size: cover;
cursor: pointer;
z-index: 2;
}
.player-play:hover {
background : url(img/active-button.png) no-repeat;
}
.player-error {
padding-top : 22%;
max-width : 854px;
margin : 0 auto;
text-align : center;
line-height : 5px;
z-index : 2
}
.player-error p {
color : #fff;
font-size : 18px;
margin : 20px auto;
}
.player-error a {
color : #fff;
font-size : 22px;
text-decoration:underline;
}
.player-hidden {
display:none!important;
visibility:hidden!important;
}
.movie-title {
font-family: 'Lobster', Georgia, Times, serif;
font-size: 40px;
line-height: 50px;
color : #fff;
text-align: center;
margin-top: 15px;
}
.movie-plot {
font-family: 'Cabin', Helvetica, Arial, sans-serif;
font-size: 15px;
line-height: 20px;
color : #ffffff;
width: 854px;
margin : 570px auto;
text-align: justify;
}
</style>
</head>
<body>
<div class="movie-title">"<?php echo $movie_title; ?>" Full Movie</div>
<div style="background: url(<?php echo $movie_background;?>); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; opacity: 0.3; filter:alpha(opacity=30); position:absolute; top:0; left:0; width:100%; height:100%;"></div>
<div style="background: url(<?php echo $movie_player;?>); background-repeat : no-repeat; background-size: cover; z-index: 1; width: 854px; height: 480px; margin: 100px auto auto; position: absolute; top:0; left:0; bottom:0; right:0; z-index: 1; border: 20px solid rgba(255, 0, 0, 0.3);" id="player-container">
<div class="player-play" id="player-play"></div>
<div class="player-error player-hidden" id="player-error">
<img src="img/error.png" alt="error">
<p>A plugin is needed to display this video.</p>
Install plugin...
</div>
</div>
<div class="movie-plot">
<img src="<?php echo $movie_poster;?>" style="float: left; width: 120px; margin:0px 10px 10px 0px;">
<p><b>Title : </b> <?php echo $movie_title; ?></p>
<p><b>Genre : </b> <?php echo $movie_genres; ?></p>
<p><b>Cast : </b> <?php echo $movie_cast; ?></p>
<p><b>Movie Plot : </b><?php echo $movie_plot;?><br><br></p>
</div>
<?php
$apikey = “my api deleted for post”;
$per_page = 6;
$search = “lucy”;
$category = “2”; //autos
$query = “https://www.googleapis.com/youtube/v3/search?part=snippet&q=$search&maxResults=$per_page&videoCategoryId=$category&safesearch=strict&key=$apikey”;
$json_file3 = file_get_contents(“$query”);
$jfo3 = json_decode($json_file3,true);
foreach($jfo3[‘items’] as $val) {
$title = $val[‘snippet’][‘title’];
$description = $val[‘snippet’][‘description’];
$id = $val[‘id’][‘videoId’];
$thumbnail_url = $val[‘snippet’][‘thumbnails’][‘default’][‘url’];
echo <<<EOF
<p><img width = “250” src = “$thumbnail_url” align = “right”></a>
<a href =”video-viewer.php?v=$id”>$title<BR>
$description</p><br clear=”all”><HR>
EOF;
?>
</body>
</html>

$query = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=".$search."&maxResults=".$per_page."&videoCategoryId=".$category."&safesearch=strict&key=".$apikey;
This should work

Related

PHP/HTML: How I could change my image source depending on the value from the database

I have HTML in my PHP file, because I'm using data from a database to display on my website. (This is my first time using PHP so my knowledge is really little)
My question is how I could change my image source depending on the value from the database.
The depending value I'm talking about is called = SENT_NUMBER_1
<?php
//This line will make the page auto-refresh each 15 seconds
$page = $_SERVER['PHP_SELF'];
$sec = "15";?>
<html>
<head>
<style>
div.image{
transform: rotate(90deg);
width:100px;
height:200px;
background: transparent;
position: absolute;
top:30%;
bottom: 0;
left: 0;
right: 0;
margin: auto;
content:url(photo) // This is the url I'm wanting to change into either: Empty.png / 25.png / 50.png / 75.png /100.png || like = content:url(/50.png)
}
</style>
<div class="image"></div>
i also have something like this but I don't know if this works, and where to put it.
if(SENT_NUMBER_1 <= 10){
photo = "10.png"
}
elseif(SENT_NUMBER_1 >= 11 && <=25){
photo = "25.png"
}
elseif(SENT_NUMBER_1 >= 26 && <=49){
photo = "50.png"
}
elseif(SENT_NUMBER_1 >= 50 && <=74){
photo = "75.png"
}
elseif(SENT_NUMBER_1 >= 75 && <=100){
photo = "100.png"
}
Here is a screenshot from the [website], the image I'm wanting to change is the battery you see on the screenshot.
Whole code for if I missed something
<?php
//This line will make the page auto-refresh each 15 seconds
$page = $_SERVER['PHP_SELF'];
$sec = "15";
?>
<html>
<head>
<link rel="shortcut icon" href="/favicon-16x16.ico" type="image/x-icon">
<title>Rattengifmelder</title>
<style>
#font-face {
font-family: Asket Extended; src: url('AsketExtended-Light.otf');
font-family: Asket Extended; font-weight: bold; src: url('AsketExtended-Light.otf');
}
body{
height: 200vh;
}
tbody{
text-align: center;
}
td{
background-color: transparent;
width: 70px;
height: 70px;
}
table, th, td{
font-size: 30px;
width: 100px;
margin-left: auto;
margin-right: auto;
background: transparent;
border: 10px solid white;
font-family: 'Asket Extended', sans-serif;
}
div.image{
transform: rotate(90deg);
width:100px;
height:200px;
background: transparent;
position: absolute;
top:30%;
bottom: 0;
left: 0;
right: 0;
margin: auto;
content:url(/100.png)
}
div.image2{
width:100px;
height:200px;
background: transparent;
content:url(/Empty.png)
}
div.image3{
width:100px;
height:200px;
background: transparent;
content:url(/Empty.png)
}
.center{
position: sticky;
top: 0px;
text-align: center;
font-family: 'Asket Extended', sans-serif;
font-size: 50px;
font-weight: bold;
padding-top: 50px;
background-color: white;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
height: 10%;
width: 100%;
background-color: white;
color: white;
text-align: center;
border-top: 1px solid lightgrey ;
}
div.container {
float: left;
margin: 100px;
padding: 20px;
width: 100px;
}
.menu{
position: absolute;
left: 70px;
top: 65px;
width:20px;
height:20px;
content:url(/menu.png)
}
.battery{
position: absolute;
left: 93%;
top: 50px;
width: 30px;
height:60px;
transform: rotate(90deg);
content:url(/100.png)
}
.one{
}
.two{
}
.three{
}
</style>
<!--//I've used bootstrap for the tables, so I inport the CSS files for taht as well...-->
<meta http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
</head>
<body>
<?php
include("database_connect.php"); //We include the database_connect.php which has the data for the connection to the database
// Check the connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Again, we grab the table out of the database, name is ESPtable2 in this case
$result = mysqli_query($con,"SELECT * FROM ESPtable2");//table select
//Now we create the table with all the values from the database
//loop through the table and print the data into the table
while($row = mysqli_fetch_array($result)) {
$column1 = "RECEIVED_BOOL1";
$column2 = "RECEIVED_BOOL2";
$column3 = "RECEIVED_BOOL3";
$column4 = "RECEIVED_BOOL4";
$column5 = "RECEIVED_BOOL5";
}
?>
<div class="center">
<div class="menu"></div>
<div class="battery"></div>
<p>Rattengifmelder</p>
</div>
<?php
include("database_connect.php");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM ESPtable2");//table select
echo "<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr class='active'>
<td style='color: grey;'>Grasveld achter</td>
</tr>
";
while($row = mysqli_fetch_array($result)) {
$cur_sent_bool_1 = $row['SENT_BOOL_1'];
$cur_sent_bool_2 = $row['SENT_BOOL_2'];
$cur_sent_bool_3 = $row['SENT_BOOL_3'];
if($cur_sent_bool_1 == 1){
$label_sent_bool_1 = "label-success";
$text_sent_bool_1 = "Actief";
}
else{
$label_sent_bool_1 = "label-danger";
$text_sent_bool_1 = "Inactief";
}
/*echo "<tr class='info'>";
$unit_id = $row['id'];
echo "<td>" . $row['id'] . "</td>"; */
echo "<td>
<span class='label $label_sent_bool_1'>"
. $text_sent_bool_1 . "</td>
</span>";
}
echo "</table>";
?>
<?php
include("database_connect.php");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM ESPtable2");//table select
echo "<table>
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr class='active'>
</tr>
";
while($row = mysqli_fetch_array($result)) {
echo "<tr class='info'>";
echo "<td style='background-color: transparent;'>" . $row['SENT_NUMBER_1'] . "% </td>";
echo "</tr></tbody>";
}
echo "</table>
<br>
";
?>
<div class="footer">
<p></p>
</div>
<div class="image"></div> // this is where the image is displayed
I didn't get where you are getting value of SENT_NUMBER_1 in your php code ??
then
SENT_NUMBER_1 should be $SENT_NUMBER_1
photo should be $photo
if($SENT_NUMBER_1 <= 10){
$photo = "10.png";
}
if($SENT_NUMBER_1 >= 11 && $SENT_NUMBER_1 <=25){
$photo = "25.png";
}
if($SENT_NUMBER_1 >= 26 && $SENT_NUMBER_1 <=49){
$photo = "50.png";
}
if($SENT_NUMBER_1 >= 50 && $SENT_NUMBER_1 <=74){
$photo = "75.png";
}
if($SENT_NUMBER_1 >= 75 && $SENT_NUMBER_1 <=100){
$photo = "100.png";
}
and then
<div class="image"><img src="<?php echo $photo;?>"></div> // this is where the image is displayed
also declare full path of image.
e.g.
$photo = 'imagefolder/100.png';

Trouble inserting a CSS Grid into a flexbox layout

I am trying to insert a CSS grid layout within a flexbox layout so that 3 "grids" flex across a page row then the next three "grids" fill another row etc. At the moment all the "grids" line up in the centre of the page in one column when they should flex into rows of three abreast.
php code for itinery list page
<?php
include("assets/includes/header.inc.php");
include("config.php");
include("classes/ItineryResultsProvider.php");
if(isset($_GET['location'])) {
$location = $_GET['location'];
}
else {
exit("You must select an itinery location");
}
$page = isset($_GET["page"]) ? $_GET["page"] : 1;
?>
<body>
<section class="PageWrapper">
<section class='PageContentContainer'>
<?php
$resultsProvider = new ItineryListProvider($conn);
$pageSize = 18;
$numResults = $resultsProvider->getNumResultsItineryList($location);
$removeUnderscoreLocation = str_replace('_', ' ', $location);
echo "<div class='PageContentListCount'>
<h2>This page shows a list of $numResults suggested itineries for $removeUnderscoreLocation.</h2>
</div>";
echo $resultsProvider->getResultsItineryList($page, $pageSize, $location)
?>
<div class="PaginationGridContainer">
<div class="PaginationGridLogo">
<img src="assets/logos/Page_Numbering.png">
</div>
<div class="PaginationGridNumbering">
<?php
$pagesToShow = 10;
$numPages = ceil($numResults / $pageSize);
$pagesLeft = min($pagesToShow, $numPages);
$currentPage = $page - floor($pagesToShow / 2);
if($currentPage < 1) {
$currentPage = 1;
}
if($currentPage + $pagesLeft > $numPages + 1) {
$currentPage = $numPages + 1 - $pagesLeft;
}
while($pagesLeft != 0 && $currentPage <= $numPages) {
if($currentPage == $page) {
echo "<div class='PageNumberContainer'>
<span class='PageNumber'>$currentPage</span>
</div>";
}
else {
echo "<div class='PageNumberContainer'>
<a href='ItineryList.php?location=$location&page=$currentPage'>
<span class='PageNumber'>$currentPage</span>
</a>
</div>";
}
$currentPage++;
$pagesLeft--;
}
?>
</div>
</div>
</section>
</section>
</body>
</html>
php code for itinery list page classes
<?php
class ItineryListProvider {
private $conn;
public function __construct($conn) {
$this->conn = $conn;
}
public function getNumResultsItineryList($location) {
$query = $this->conn->prepare("SELECT COUNT(*) as total
FROM bth_itn_tbl WHERE ITN_STATUS='1'
AND ITN_LOCATION LIKE :location");
$searchTerm = $location;
$query->bindParam(":location", $searchTerm);
$query->execute();
$row = $query->fetch(PDO::FETCH_ASSOC);
return $row["total"];
}
public function getResultsItineryList($page, $pageSize, $location) {
$fromLimit = ($page - 1) * $pageSize;
$query = $this->conn->prepare("SELECT *
FROM bth_itn_tbl WHERE ITN_STATUS='1'
AND ITN_LOCATION LIKE :location
ORDER BY ITN_CLICK_COUNT DESC
LIMIT :fromLimit, :pageSize");
$searchTerm = $location;
$query->bindParam(":location", $searchTerm);
$query->bindParam(":fromLimit", $fromLimit, PDO::PARAM_INT);
$query->bindParam(":pageSize", $pageSize, PDO::PARAM_INT);
$query->execute();
$resultsItineryList = "<div>";
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$id = $row["ITN_KEY"];
$itnImg = $row["ITN_IMG_PATH"];
$title = $row["ITN_TITLE"];
$resultsItineryList .= "<div class='ItineryListFlexbox'>
<div class='ItineryListGrid'>
<a class='IntineryListGridImage'>
<img src='$itnImg' height='169' width='225'>
</a>
<a class='ItineryListGridTitle'>$title</a>
</div>
</div>";
}
$resultsItineryList .= "</div>";
return $resultsItineryList;
}
}
?>
CSS code. Note that the PageWrapper and PageContentContainer is generic for all pages and works fine. The issue is with the ItineryListGrid which is supposed to flex within ItineryListFlexbox. At the moment it is a vertical centred column within the PageContentContainer
.PageWrapper {
padding-top: 100px;
margin-bottom: 20px;
width: 100%;
display: flex;
justify-content: center;
flex-flow: row;
}
.PageContentContainer {
float: left;
margin: 0px 5px 5px 5px;
width: 710px;
border: 2px solid #111;
border-radius: 4px;
box-shadow: 6px 6px 4px #888888;
}
.PageContentListCount h2 {
margin: 20px 10px 20px 10px;
margin-left: 10px;
font-family: Catamaran;
font-size: 25px;
line-height: 30px;
font-weight: 900;
color: #111;
justify-content: left;
}
.PageContentContainer h3 {
margin: 0 0 15px 10px;
font-family: Catamaran;
font-size: 18px;
font-weight: 900;
color: #111;
}
.AdvertisingContainer {
float: right;
margin: 0px 15px 5px 5px;
width: 320px;
border: 2px solid #111;
border-radius: 4px;
box-shadow: 6px 6px 4px #888888;
height: auto;
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: auto;
}
.ItineryListFlexbox {
display: flex;
flex-flow: row wrap;
justify-content: center;
height: auto;
}
.ItineryListGrid {
margin: 10px;
display:grid;
grid-template-columns: 225px;
grid-template-rows: 169px 50px;
grid-template-areas:
"IntineryListGridImage"
"ItineryListGridTitle";
}
.IntineryListGridImage {
grid-area: IntineryListGridImage;
}
.ItineryListGridTitle {
grid-area: ItineryListGridTitle;
text-align: left;
margin: 5px 0 5px 0;
text-decoration: none;
font-family: Catamaran;
font-size: 18px;
line-height: 20px;
font-weight: 900;
text-align: center;
color: #111;
}

Uninitialized string offset: 36 Error ONLY when reloading page

I'm getting an error in my php page only when I reload it and sometimes it also comes without any warning..
I was trying to make a page where the user's can paste thier code and get the link to share it. The thing work's, but the error(s) on the main page are annoying.
Here's my full page code:
<?php
header("X-XSS-Protection: 1");
date_default_timezone_set("America/New_York");
function getUserIP()
{
$client = #$_SERVER['HTTP_CLIENT_IP'];
$forward = #$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
elseif(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
else
{
$ip = $remote;
}
return $ip;
}
$user_ip = getUserIP();
// for generating random filenames
$chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
$namelength = 35;
$randomfilename = '';
for($i = 0; $i < $namelength; $i++)
{
$randomfilename .= $chars[mt_rand(0, 36)];
}
if($_POST)
{
$title = $_POST['postTitle'];
$content = $_POST['postContent'];
$filename = $randomfilename;
$fname = $filename;
$filename = 'pastes/' . $filename . '.html';
$refresh = "Refresh:0; url=" . $filename;
$date = date("Y.m.d");
$time = date("h:i:sa");
if(strlen($title) > 100)
{
echo "<script>alert('Max 100 Characters Allowed!');</script>";
}
else if(strlen($title) <= 100)
{
$content = nl2br($content);
$content = filter_var($content, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_SANITIZE_ENCODED);
$title = filter_var($title, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_SANITIZE_ENCODED);
$fname = filter_var($fname, FILTER_SANITIZE_FULL_SPECIAL_CHARS, FILTER_SANITIZE_ENCODED);
$link = 'http://openpaste.000webhostapp.com/' . $filename;
$handle = fopen($filename, "a");
fwrite($handle, "<html><head><title>" . $fname . "</title><link rel='stylesheet' href='style.css'></head><body><h1>" . $title . "</h1>" . "DATE: " . $date . "<br>TIME: " . $time . "<h2>Your File Link: " . $link . "</h2><p>" . $content . "</p><br></body></html>");
fclose($handle);
$f = fopen("ip.txt", "a");
fwrite($f, $user_ip . "\n");
fclose($f);
header($refresh);
}
}
?>
<html>
<head>
<title>OpenPaste | Home</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="overlay.css">
<style>
body{
margin: 0px;
font-size: 17px;
}
.nav{
background-color: royalblue;
padding: 2px;
font-family: georgia, sans-serif, tahoma, arial;
}
.nav font,a{
font-size: 25px;
text-decoration: none;
}
#icomenu{
width: 30px;
height: 30px;
margin-left: 10px;
margin-right: 10px;
border: none;
border-radius: 5px;
opacity: 0.7;
}
#icomenu:hover{
cursor: pointer;
opacity: 1.0;
box-shadow: 0px 0px 5px black;
}
.overlay-content a{
color: #ffffff;
}
.overlay-content a:hover{
color: yellow;
}
.content{
margin: 0;
padding: 1em;
background-color: firebrick;
}
form{
margin: 30px 0px 30px 0px;
font-family: sans-serif, georgia, sans, tahoma, arial;
font-size: 17px;
}
form input{
width: 50%;
text-align:center;
border:none;
border-radius: 10px;
padding: 2px;
margin-top: 5px;
font-family: sans-serif, georgia, sans, tahoma, arial;
font-size: 17px;
text-shadow: 5px 5px 10px #333;
}
form textarea{
width: 50%;
margin-top: 10px;
border: none;
border-radius: 10px;
padding: 2px;
height: 50%;
font-family: sans-serif, georgia, sans, tahoma, arial;
font-size: 17px;
}
form button{
border: none;
background-color: lime;
color: black;
padding: 5px 25px;
margin-top: 5px;
font-family: sans-serif, georgia, sans, tahoma, arial;
font-size: 17px;
}
form button:hover{
background-color: royalblue;
color: white;
cursor: pointer;
}
</style>
<script type="text/javascript">
function openNav() {
document.getElementById("myNav").style.width = "100%";
}
function closeNav() {
document.getElementById("myNav").style.width = "0%";
}
</script>
</head>
<body>
<!-- NAVIGATION -->
<div id="myNav" class="overlay">
×
<div class="overlay-content">
Home<br>
Our Projects<br>
About<br>
Contact<br>
</div>
</div>
<div class="nav">
<img id="icomenu" src="img/menu.png" onclick="openNav();">
<font color="white">OpenPaste</font>
</div>
<!-- BODY -->
<div class="main">
<div class="content">
<center>
<form action="" method="POST">
<input type="text" name="postTitle" placeholder="Your Title"><br>
<textarea rows="" cols="" name="postContent" placeholder="Your Paste.."></textarea><br>
<button type="submit" name="submit" value="Submit">Create Post</button>
</form>
</center>
</div>
</div>
</body>
</html>
I have tried setting the error message to off, but still want to know why I get the error?
Here is the image of the error: Error Image Here.
You can find my project files here: GitHub Project Repo incase you think that some asset is giving the problem.
Thanks in advance :)
EDIT: Thanks for replies :D
You need to change:-
$randomfilename .= $chars[mt_rand(0, 36)];
to
$randomfilename .= $chars[mt_rand(0, strlen($chars)-1)];
Because last index of $chars is 35 not 36 (as it started from 0 index).

PHP Default value and Print Issues

I am currently trying to make my php, on the same page as the form, display the values correctly and calculate the overall passer rating. My calculations follow the formatting this way:
C = ((# completions/#attempts) *100 -30)/20
Y= ((# yards/#attempts) -3)/4
T = ((#touchdowns/#attempts) *20)
I = 2.375 - (#interceptions/#attempts) * 35
Pass Rating = ((C+Y+T+I)/6) *100
The table that holds the values from the form should have a default value of 0 and below it should print the overall rating of Poor, Good and Great depending on the passer rating.
As you see I have a few issues.
My issues are:
The Passing Rating doesn't default to 0.
My Overall Rating doesn't print whether it is Poor, Good, or Great. It only prints Poor
I was hoping someone can explain this. I have been troubleshooting it for hours now. No luck sadly. ps(overall rating printed twice to see which version I want to use)
Also the snippet won't run the php unless you have php on your comp. Need a server to see it even with the snippet I guess
UPDATE: I put 20 instead of 4 to divide in Y value. That fixed my calculations but not the overall rating.
SECOND UPDATE: I added the line:
if(($_POST['First'] != '') && ($_POST['Last'] != ''))
so that I can keep my defaults for the table.
My last issues is now the Overall Rating displaying the correct label of either Poor, Good or Great
<?php
$first = "";
$last = "";
$completions = 0;
$attempts = 0;
$yards = 0;
$touchdowns = 0;
$interceptions = 0;
$TotalScores = 0;
if(isset($_POST['First'])) {
$first = $_POST['First'];
}
if(isset($_POST['Last'])){
$last = $_POST['Last'];
}
if(isset($_POST['completions'])) {
$completions = $_POST['completions'];
}
if(isset($_POST['attempts'])) {
$attempts = $_POST['attempts'];
}
if(isset($_POST['yards'])){
$yards = $_POST['yards'];
}
if(isset($_POST['touchdowns'])) {
$touchdowns = $_POST['touchdowns'];
}
if(isset($_POST['interceptions'])) {
$interceptions = $_POST['interceptions'];
}
function rating ($com, $att, $yards, $touchd, $inter){
//$C = 0;
//$Y = 0;
//$T = 0;
//$I = 0;
$passRating = 0;
$C = ((($com /$att)*100)-30) / 20;
$Y = (($yards/$att)-3)/4;
$T = ($touchd/$att)*20;
$I = 2.375 - (($inter/$att)*35);
$passRating = (($C + $Y + $T + $I)/6)*100;
return $passRating;
}
if(is_numeric($completions) && is_numeric($attempts) && is_numeric($yards)
&& is_numeric($touchdowns) && is_numeric($interceptions)) {
//if(($_POST['completions'] >0) && ($_POST['attempts'] >0) && ($_POST['yards'] >0)
// && ($_POST['touchdowns'] >0) && ($_POST['interceptions'] >0) ){
if(($_POST['First'] != '') && ($_POST['Last'] != '')){
$TotalScore = rating($completions, $attempts, $yards,
$touchdowns, $interceptions);
//echo $TotalScore;
if ($TotalScore < 85 && $TotalScore >0){
$score = "Poor";
}
elseif($TotalScore >=85 && $TotalScore <90){
$score = "Mediocre";
}
elseif ($TotalScore >=90 && $TotalScore <95){
$score = "Good";
}
elseif ($score >= 95){
$score = "Great";
}
}
//}
}
else {
$score = "Invalid Input!";
//echo $TotalScore;
}
?>
.form-container {
padding-right: 20px;
}
fieldset {
width: 200px;
height: 30px;
padding: 5px;
}
input {
padding-bottom: 5px;
}
#text-container {
margin-top: 100px;
width: 1260px;
height: 400px;
background-color: white;
text-align: left;
margin-left: auto;
margin-right: auto;
border-radius: 10px;
}
#text-container p {
margin-left: 30px;
font-size: 20px;
}
#text-container h1 {
margin-left: 30px;
color: #4EA24E;
padding-top: 10px;
}
#paragraph {
position: absolute;
width: 1350px;
height: 600px;
border: 1px solid black;
margin-left: 500px;
margin-top: 60px;
}
.signup {
float: right;
height: 600px;
width: 500px;
border: 1px solid black;
background-color: blue;
}
#form-box {
margin-top: 10px;
width: 550px;
height:600px;
maring-left: 0;
float: left;
/*background-color: #B2D1F0;*/
/*border-radius: 30px;*/
/*box-shadow: 0 0 10px black;*/
}
#form-box label {
float: left;
width: 200px;
text-align: right;
margin-right: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
font-size: 20px;
margin-bottom: 30px;
margin-left: 20px;
}
#form-box input[type="text"] {
margin-bottom: 30px;
height: 20px;
width: 200px;
font-size: 15px;
margin-left: 10px;
box-shadow: 0 0 5px black;
}
.numInput input[type="text"] {
margin-bottom: 30px;
height: 20px;
width: 50px;
font-size: 15px;
margin-left: 10px;
box-shadow: 0 0 5px black;
}
#form-box button {
margin-bottom: 30px;
height: 35px;
width: 100px;
font-size: 25px;
margin-right: 100px;
float: right;
background-color: #4EA24E;
color: orange;
border-radius: 5px;
text-shadow: 0 0 10px black;
box-shadow: 0 0 10px black;
font-family: Rockwell, 'Courier Bold', serif
}
#form-box button:hover {
color: gold;
}
#form-box h1{
text-align: left;
margin-right: 65px;
color: #4EA24E;
font-size: 35px;
margin-bottom: 0;
text-shadow: 0 0 1px black;
margin-left: 30px;
}
#form-box h2{
text-align: right;
margin-right: 85px;
color: #114611;
}
#calcContainer {
clear: both;
width: 200px;
height: 500px;
float: left;
margin-top: 600px;
border: 1px solid black;
}
.table {
margin-top: 20px;
}
.table td, .table tr {
border: 1px solid black;
width: 150px;
}
.table h3 {
margin-top: 40px;
}
/*table {
margin-top: 200px;
}
td , tr{
border: 1px solid black;
width: 150px;
}
*/
span {
margin-left: 40px;
}
#screen {
}
html {
margin: 0;
padding: 0;
min-width: 960px;
max-width: 1000px;
background: url(bubbles.jpg) no-repeat;
height: 100%;
background-size: 960px 960px;
//margin-bottom: 100px;
}
#footer {
width:100%;
height:100px !important;
border-top:4px solid black;
background-color:orange;
//position: relative;
//bottom: 0;
margin-bottom: 0 auto;
//position: fixed;
z-index: 10;
clear: both;
margin-top: 500px;
margin-left: 30px;
}
#footer-inner {
width:80%;
margin:0 auto 0 auto;
height:inherit;
}
body {
margin-bottom: 100px;
margin-right: 30px;
padding: 0;
width: 100%;
height: 100%;
}
h1.name{
/*font-family: Lato, 'Courier Bold', sanserif;*/
font-family: 'KOMIKAX_';
src: url(KOMIKAX_.tff);
font-weight: bold;
font-variant: small-caps;
color: "red";
margin-left: 30px;
text-shadow: 0 0 1px black;
}
#header {
margin-left: 30px;
width:100%;
}
#gradient {
height: 65px;
/* IE 10 */
background-image: -ms-linear-gradient(top, black 0%, orange 100%);
/* Firefox */
background-image: -moz-linear-gradient(top, black, orange);
/* Safari & Chrome */
background-image: -webkit-gradient(linear,left bottom,left top, color-stop(0, orange),color-stop(1, black));
box-shadow: inset 0 0 15px black;
}
#nav1 {
list-style: none;
}
#nav2 {
list-style: none;
}
.nav a {
text-decoration: none; /*remove underline*/
text-transform: uppercase;
color: white;
font-family: Rockwell, 'Courier Bold', serif;
font-size: 20px;
padding-bottom: 15px;
}
.nav li {
display: inline;
float: left;
padding: 10px;
}
.nav a:visited {
text-decoration: none;
color: #fff;
}
.nav a:hover {
text-decoration: none;
color: black;
background-color:transparent;
}
.nav a:active {
text-decoration: none;
color: #19A3FF;
}
.container {
margin-left: 30px;
height: 560px;
background-color: black;
width: 1000px;
border-radius: 3px;
float: left;
}
.text-left {
float: left;
padding-left: 30px;
}
.text-right {
float: right;
padding-right: 55px;
}
.text-center {
float: center;
margin: auto 0;
}
.MainImage {
background-image: url(http://cdn2.sportngin.com/attachments/photo/2021/8243/football_large.jpg);
height: 300px;
background-repeat: no-repeat;
width:99.8%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: 100%;
padding-bottom: 30px;
display: block;
border: 1px solid;
margin-left: 30px;
opacity: 0.9;
filter: alpha(opacity=90); /* For IE8 and earlier */
}
h1.title {
color: white;
padding-left: 30px;
padding-top: 10px;
font-size: 60px;
font-family: Rockwell, 'Courier Bold', serif;
font-variant: small-caps;
font-weight: bold;
text-shadow: 0 0 3px black;
margin-bottom: 0;
}
#sub {
color: white;
padding-left: 80px;
font-size: 30px;
font-family: Rockwell, 'Courier Bold', serif;
font-variant: small-caps;
text-shadow: 0 0 8px black;
}
/*.highlight {
/*text-shadow: 0 0 10px #E6FFFF;*/
text-shadow: 0 0 10px rgba(255,255,255,1) , 0 0 20px rgba(255,255,255,1) , 0 0 30px rgba(255,255,255,1) , 0 0 40px #ff00de , 0 0 70px #ff00de , 0 0 80px #ff00de , 0 0 100px #ff00de ;
filter: glow(color=#E6FFFF, strength=3);
color: red;
}*/
#sidebar {
height: 1200px;
width: 400px;
float: left;
background-color: #99CC99;
margin-top: 50px;
font-size: 25px;
margin-right: 0;
}
#main-container {
width: 1260px;
height: 230px;
margin-top: 30px;
postion: relative;
margin-left: auto;
margin-right: auto;
margin-bottom: 0;
}
#main-container2 {
width: 1260px;
height: 230px;
postion: relative;
margin-left: auto;
margin-right: auto;
margin-top: 0;
}
#columns {
float: left;
width: 370px;
height: 230px;
background-color: #ECF2F8;
text-align: center;
display: inline-block;
vertical-align: top;
margin-left: 20px;
border-radius: 10px;
box-shadow: 0 0 10px black;
padding-left: 10px;
padding-right: 10px;
border: 1px solid black;
}
#columns-image {
foat: left;
width: 390px;
border: 1px solid black;
height: 230px;
display: inline-block;
margin-left: 18px;
border-radius: 5px;
border: 1px solid black;
}
#bar-left {
height: 230px;
width: 30px;
background-color: blue;
float: left;
margin-right: 20px;
margin-top: 30px;
margin-left: 0;
}
#bar-right {
height: 230px;
width: 30px;
background-color: blue;
float: left;
}
#bullet {
list-style-Type: none;
padding: 0 0 4px 23px;
background: ur(http://www.computerhope.com/arrow.gif) no-repeat left top;
}
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "stylesheet.css" type = "text/css">
<link rel = "stylesheet" href = "formstylesheet.css" type = "text/css">
<meta http-equiv="X-UA-Compatible" content="IE=80" />
</head>
<div id = "screen">
<body>
<h1 class = "name"><font color = "orange" font size = "20px"> Passer Ratings | </font><font size = "12" font color = "#4EA24E"> Monitor Your Results to Improve!</font></h1>
<div id = "header">
<div id = "gradient">
<div class = "nav">
<!-- container-fluid gives full width container of whole viewport -->
<div class = "container-fluid">
<ul id = "nav1" class= "text-left">
<li><strong>Home</li>
<li>About Us</li>
<li>Teach</li>
<li>Score Board</strong></li>
</ul>
<ul id = "nav2" class = "text-right">
<li><strong>Contact</strong></li>
</ul>
</div><!-- end container-fluid-->
</div><!--end nav-->
</div>
</div> <!-- end header -->
<div id = "Main">
<div class = "MainImage">
<h1 class = "title"> Knowing your Strengths and Weaknesses..<br></h1>
<p id = "sub"><font color= "#4DFFFF"><strong> Makes</strong>
</font> a great player... </p>
</div><!-- end MainImage-->
<form id ="form-box" action = 'passrating.php' method = 'post'>
<h1>Calculate Passer Rating<br><br>
<h2>Submit to Review the information </h2>
<label>First Name </label>
<input type="text" name = 'First' placeholder='First'/><br/>
<label>Last Name:</label>
<input type="text" name = 'Last' placeholder='Last'/><br/>
<label>Pass Completions</label>
<input type="text" name = 'completions' value = 0 class = 'numInput'><br/>
<label>Pass Attempts:</label>
<input type="text" name = 'attempts' value = 0><br/>
<label>Total Passing Yards:</label>
<input type="text" name = 'yards' value = 0><br/>
<label>Touchdowns:</label>
<input type="text" name = 'touchdowns' value = 0><br/>
<label>Interceptions:</label>
<input type="text" name = 'interceptions' value = 0><br/>
<button type="reset" value="Reset">Reset</button>
<button type="submit" value="Submit">Submit</button>
</form>
<div class='calcContainer'>
<table class='table' action = 'passrating.php' method = 'post'>
<h3>Totals for Calculations</h3>
<tr> Test Case:<?php echo "\t" .$first. "\t" .$last; ?></tr>
<tr>
<td>Pass Completions </td>
<td width = "20px"><span value = 0><?php echo $completions; ?></td>
</tr>
<tr>
<td>Pass Attempts </td>
<td><span value = 0><?php echo $attempts; ?></td>
</tr>
<tr>
<td>Total Passing Yards </td>
<td><span value = 0><?php echo $yards; ?></td>
</tr>
<tr>
<td>Touchdowns </td>
<td><span value =0><?php echo $touchdowns; ?></td>
</tr>
<tr>
<td>Interceptions: </td>
<td><span value = 0 ><?php echo $interceptions; ?></td>
</tr>
<tr>
<td>Passing Rating: </td>
<td><span value = 0 ><?php echo $TotalScore; ?></td>
</table>
<p value = " ">The Overall Rating is: <?php echo $score; ?></p>
<p value = ""><?php echo "The Overall Rating is: " .$score. "</br>"; ?></p>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<link rel = "stylesheet" href = "stylesheet.css" type = "text/css">
<link rel = "stylesheet" href = "formstylesheet.css" type = "text/css">
<meta http-equiv="X-UA-Compatible" content="IE=80" />
</head>
<div id = "screen">
<body>
<h1 class = "name"><font color = "orange" font size = "20px"> Passer Ratings | </font><font size = "12" font color = "#4EA24E"> Monitor Your Results to Improve!</font></h1>
<div id = "header">
<div id = "gradient">
<div class = "nav">
<!-- container-fluid gives full width container of whole viewport -->
<div class = "container-fluid">
<ul id = "nav1" class= "text-left">
<li><strong>Home</li>
<li>About Us</li>
<li>Teach</li>
<li>Score Board</strong></li>
</ul>
<ul id = "nav2" class = "text-right">
<li><strong>Contact</strong></li>
</ul>
</div><!-- end container-fluid-->
</div><!--end nav-->
</div>
</div> <!-- end header -->
<div id = "Main">
<div class = "MainImage">
<h1 class = "title"> Knowing your Strengths and Weaknesses..<br></h1>
<p id = "sub"><font color= "#4DFFFF"><strong> Makes</strong>
</font> a great player... </p>
</div><!-- end MainImage-->
<form id ="form-box" action = 'passrating.php' method = 'post'>
<h1>Calculate Passer Rating<br><br>
<h2>Submit to Review the information </h2>
<label>First Name </label>
<input type="text" name = 'First' placeholder='First'/><br/>
<label>Last Name:</label>
<input type="text" name = 'Last' placeholder='Last'/><br/>
<label>Pass Completions</label>
<input type="text" name = 'completions' value = 0 class = 'numInput'><br/>
<label>Pass Attempts:</label>
<input type="text" name = 'attempts' value = 0><br/>
<label>Total Passing Yards:</label>
<input type="text" name = 'yards' value = 0><br/>
<label>Touchdowns:</label>
<input type="text" name = 'touchdowns' value = 0><br/>
<label>Interceptions:</label>
<input type="text" name = 'interceptions' value = 0><br/>
<button type="reset" value="Reset">Reset</button>
<button type="submit" value="Submit">Submit</button>
</form>
<div class='calcContainer'>
<table class='table' action = 'passrating.php' method = 'post'>
<h3>Totals for Calculations</h3>
<tr> Test Case:<?php echo "\t" .$first. "\t" .$last; ?></tr>
<tr>
<td>Pass Completions </td>
<td width = "20px"><span value = 0><?php echo $completions; ?></td>
</tr>
<tr>
<td>Pass Attempts </td>
<td><span value = 0><?php echo $attempts; ?></td>
</tr>
<tr>
<td>Total Passing Yards </td>
<td><span value = 0><?php echo $yards; ?></td>
</tr>
<tr>
<td>Touchdowns </td>
<td><span value =0><?php echo $touchdowns; ?></td>
</tr>
<tr>
<td>Interceptions: </td>
<td><span value = 0 ><?php echo $interceptions; ?></td>
</tr>
<tr>
<td>Passing Rating: </td>
<td><span value = 0 ><?php echo $TotalScore; ?></td>
</table>
<p value = " ">The Overall Rating is: <?php echo $score; ?></p>
<p value = ""><?php echo "The Overall Rating is: " .$score. "</br>"; ?></p>
</div>
</div>
</body>
</html>
What I did to fix my issues:
if(is_numeric($completions) && is_numeric($attempts) && is_numeric($yards)
&& is_numeric($touchdowns) && is_numeric($interceptions)) {
//if(($_POST['completions'] >0) && ($_POST['attempts'] >0) && ($_POST['yards'] >0)
// && ($_POST['touchdowns'] >0) && ($_POST['interceptions'] >0) ){
if(($_POST['First'] != '') && ($_POST['Last'] != '')){
// $TotalScore = rating($completions, $attempts, $yards,
// $touchdowns, $interceptions);
if(($_POST['completions'] <0) || ($_POST['attempts'] <0) || ($_POST['yards'] <0)
|| ($_POST['touchdowns'] <0) || ($_POST['interceptions'] <0) ){
$score = "</br></br><strong>Invalid Input!</strong></br>Please Provide non-Negative Numbers.";
}
//echo $TotalScore;
else {
$TotalScore = rating($completions, $attempts, $yards,
$touchdowns, $interceptions);
if($TotalScore < 0) {
$score = "</br></br><strong>Invalid Results</strong></br>Please review over your scores. The Passing Rating shouldn't be negative.";
}
if($TotalScore > 0 && $TotalScore <85){
$score = "Poor";
}
elseif($TotalScore >=85 && $TotalScore <90){
$score = "Mediocre";
}
elseif ($TotalScore >=90 && $TotalScore <95){
$score = "Good";
}
elseif ($TotalScore >= 95){
$score = "Great";
}
}
//}
}
}
You could use my tiny library ValueResolver in this case, for example:
$value = ValueResolver::resolve('', 'default value'); // returns 'default value' because first argument is empty
and don't forget to use namespace use LapaLabs\ValueResolver\Resolver\ValueResolver;
There are also ability to typecasting, for example if your variable's value should be integer, so use this:
$id = ValueResolver::toInteger('6 apples', 1); // returns 6
$id = ValueResolver::toInteger('There are no apples', 1); // returns 1 (used default value)
Check the docs for more examples

CSS: Overflow in a DIV horizontally

I'm developing an application that contains a table made ​​by div. The divs are filled according to the results database.
As you can see in the image below.
However, if I put one more item on the bench, just disrupting the entire table. What I would do is to put a rod horizontally so that it could rotate it and so see the other items in the database without messing up the structure.
CODE
CSS
#fundo {
display: block;
height: 550px;
margin-left: -3%;
overflow: scroll;
overflow-y: hidden;
width: 1150px;
}
.vacina, .dose, .aplicacao {
background-color: #D3D3D3;
border-radius: 5px;
float: left;
height: 90px;
margin-top: 6px;
margin-left: 6px;
position: relative;
width: 100px;
}
.vacina {
height: 50px;
}
PHP
include_once ("db.php");
$sql = "SELECT nomeVacina FROM vacina ORDER BY cod";
$ds1=mysql_query($sql);
if ($ds1) {
if (mysql_num_rows($ds1) > 0) {
$x = 0;
///////////////////////////////////////////////
////////////////// DIV VACINA /////////////////
while($linha=mysql_fetch_assoc($ds1)) {
$x++;
if(!($linha['nomeVacina'] == "Outras")) {
echo "<div class='vacina' id='".$x."'>";
echo "<br>".$linha['nomeVacina'];
echo "</div>";
}
}
}
///////////////////////////////////////////////
////////////////// FIM DIV VACINA /////////////
///////////////////////////////////////////////
////////////////// DIV DOSE ///////////////////
for($i = 1; $i < 6; $i++) {
echo "<br><br><br><br><br><br>";
echo "<div class='dose'>";
if($i == 4 || $i == 5) {
echo "<br>Reforco";
}
else {
echo "<br>Dose ".$i;
}
echo "</div>";
///////////////////////////////////////////////
////////////////// FIM DIV DOSE ///////////////
///////////////////////////////////////////////
////////////////// DIV APLICACAO //////////////
$z=0;
for($j = 1; $j <= $x; $j++) {
$sql2 = "SELECT DATE_FORMAT(dataAplicacao, '%d/%m/%Y') AS dataAplicacao, loteVacina, descricaoVacina FROM vacinaaplicada WHERE dose = ".$i." AND codigoVacina = ".$j." AND codPaciente = '".$cns."'";
$ds2=mysql_query($sql2);
$linha2=mysql_fetch_assoc($ds2);
$z++;
echo "<div class='aplicacao' id='".$z.$i."'>";
if($linha2 == "") {
echo "";
}
else {
echo "<div style='margin-top:10px;'>". $linha2['descricaoVacina']."<div class='fonte'><b>Data</b><br></div>". $linha2['dataAplicacao'] . "<div class='fonte'><b>Lote</b><br></div>".$linha2['loteVacina']."</div>" ;
}
echo "</div>";
}
///////////////////////////////////////////////
////////////////// FIM DIV APLICACAO /////////////
}
As you can see in the previous image, has 9 div class Vacina.
If I add a div class Vacina the most, will mess up the table.
What I'd like is to insert more than 9 div class Vacina causing the background div (div class includes all div) increase in width, but leaving it the same way the image, just putting a scroll bar horizontally to display whole div.
If I understood you correctly, I'd try this:
To #fundo, add
white-space: nowrap;
And I replaced float: left; with:
display: inline-block;
Maybe that's what you're looking for.
EDIT:
Okay, I've built an example from scratch (but using javascript, not php, I can't test php atm): JSFiddle.
It's a bit messy but you should be able to code it in PHP if you like to.
Let me know if you've got trouble with this.
EDIT 2:
Just to have it in the answer (not just in its comments), the final solution is: this JSFiddle.
HTML + PHP
<?php
include_once("sessao.php");
if (!isset($_SESSION['funcionario']['cpfFuncionario'])) {
header("Location:index.html");
}
else if($_SESSION['funcionario']['adicionarDireito'] == 0) {
header("Location:funcionario.php");
}
?>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<title>Vacina Digital - Cadastrar Vacinação</title>
<script type="text/javascript" src="template/js/script.js"></script>
<link rel="stylesheet" href="template/css/reset.css">
<link rel="stylesheet" href="template/css/fonts.css">
<style>
body {
background-color: #fdfdfd;
overflow-y: auto;
}
#form {
margin-left: 50px;
padding-left: 7%;
padding-top: 50px;
padding-bottom: 10px;
margin-right: 50px;
border: 1px solid #0F935A;
border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-moz-box-shadow: 2px 2px 2px #cccccc;
-webkit-box-shadow: 2px 2px 2px #cccccc;
box-shadow: 2px 2px 2px #cccccc;
}
#form h1 {
text-align: center;
margin-right: 150px;
font-family: "RobotoCondensed";
font-size: 30px;
}
</style>
</head>
<body>
<?php
include_once 'menufuncionario.php';
?>
<div id="form">
<fieldset>
<?php
include_once("db.php");
if(isset($_POST['cns'])) {
$cns = $_POST['cns'];
$_SESSION['paciente'] = $cns;
}
else{
$cns = $_SESSION['paciente'];
}
$sql = "SELECT *, DATE_FORMAT(dataNascimento, '%d/%m/%Y') AS 'data' FROM populacao WHERE codigoCns = ".$cns;
$ds1=mysql_query($sql);
if ($ds1) {
if (mysql_num_rows($ds1) > 0) {
$sql2 = "SELECT * FROM vacinaaplicada WHERE codPaciente = ".$cns;
$ds2 = mysql_query($sql2);
$linha=mysql_fetch_assoc($ds2);
$linha2=mysql_fetch_assoc($ds1);
$data_nasc = $linha2['data'];
$data_nasc=explode("/",$data_nasc);
$data=date("d/m/Y");
$data=explode("/",$data);
$anos=$data[2]-$data_nasc[2];
if ($data_nasc[1] > $data[1]) {
$anos = $anos-1;
} if ($data_nasc[1] == $data[1]) {
if ($data_nasc[0] <= $data[0]) {
$anos = $anos;
} else {
$anos = $anos-1;
}
} if ($data_nasc[1] < $data[1]) {
$anos = $anos;
}
$data2=date("d/m/Y");
echo "<h1>Carteira de Vacinação - ".$linha2['nomeCrianca']."</h1>";
/*echo "
<div id='caderneta' style='margin-left:-6%'>
";*/
include_once 'caderneta.php';
echo "
</div>";
} else {
echo "<h1>CNS Inválido</h1><br><br>
<center><a href='javascript:window.history.go(-1)'><button style='margin-left:-150px' class='button button-red' href='javascript:window.history.go(-1)'>Voltar</button></a></center>
";
}
}
?>
</div>
</body>
</html>
Caderneta
<html>
<head>
<link rel="stylesheet" href="template/css/fonts.css">
<style type="text/css">
#fundo {
min-width: 800px;
display: block;
overflow: scroll;
overflow-y: hidden;
margin-left: -3%;
height: 550px;
white-space: nowrap;
}
#pinguim, .vacina, .dose, .aplicacao {
width: 100px;
height: 90px;
background-color: #D3D3D3;
margin-top: 6px;
margin-left: 6px;
border-radius: 5px;
position: relative;
float: left;
}
#pinguim, .vacina {
height: 50px;
}
.vacina, .dose{
background: green;
font-family: RobotoCondensed;
font-size: 14pt;
text-align: center;
color: #ffffff;
}
.vacina{
padding-top: -14px;
line-height: 15px;
}
.dose, .aplicacao{
margin-top: -32px;
}
.dose{
line-height: 29px;
}
.aplicacao, .fonte {
font-family: "RobotoLight";
text-align: center;
}
</style>
</head>
<body>
<div id = "fundo">
<div id = "pinguim">
</div>
<?php
include_once ("db.php");
$sql = "SELECT nomeVacina FROM vacina ORDER BY cod";
$ds1=mysql_query($sql);
if ($ds1) {
if (mysql_num_rows($ds1) > 0) {
$x = 0;
$k = 0;
while($linha=mysql_fetch_assoc($ds1)) {
$x++;
if(!($linha['nomeVacina'] == "Outras")) {
echo "<div class='vacina' id='".$x."'>";
echo "<br>".$linha['nomeVacina'];
echo "</div>";
}
}
for($i = 1; $i < 6; $i++) {
echo "<br><br><br><br><br><br>";
echo "<div class='dose'>";
if($i == 4 || $i == 5) {
echo "<br>Reforco";
}
else {
echo "<br>Dose ".$i;
}
echo "</div>";
$z=0;
for($j = 1; $j <= $x; $j++) {
$sql2 = "SELECT DATE_FORMAT(dataAplicacao, '%d/%m/%Y') AS dataAplicacao, loteVacina, descricaoVacina FROM vacinaaplicada WHERE dose = ".$i." AND codigoVacina = ".$j." AND codPaciente = '".$cns."'";
$ds2=mysql_query($sql2);
$linha2=mysql_fetch_assoc($ds2);
$z++;
echo "<div class='aplicacao' id='".$z.$i."'>";
if($linha2 == "") {
echo "";
}
else {
echo "<div style='margin-top:10px;'>". $linha2['descricaoVacina']."<div class='fonte'><b>Data</b><br></div>". $linha2['dataAplicacao'] . "<div class='fonte'><b>Lote</b><br></div>".$linha2['loteVacina']."</div>" ;
}
echo "</div>";
}
}
echo"</div>";
}
}
?>
</div>
</div>
</body>
</html>

Categories