I have a little template and in this template I have a query from database.
The name of the page is test.php and the code is:
This is the main page where i echo the content is named test.php
<?php include "components/header.php"; ?>
<div class="container">
<!-- Jumbotron -->
<?php
if (isset($_GET['user']))
{
$user = $_GET['user'];
}
else
{
die("Not found");
}
$result = mysqli_query($con, "SET NAMES utf8");
$query = "SELECT * FROM users WHERE fk_music=".$user;
$res = mysqli_query($con, $query);
$row = mysqli_fetch_assoc($res);
echo $row['text'];?>
</div>
<?php include "components/footer.php"; ?>
Now with the echo $row['text'] I have to echo all the content from the page, and in header.php are the data like <html><header><title></title></header> etc. How can I put a title foreach data from database dynamic?
There is the code from header.php
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>???</title>
<!-- Bootstrap core CSS -->
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="http://getbootstrap.com/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<link rel="stylesheet" href="/css/media-queries.css">
<link rel="stylesheet" href="/style.css">
<!--Hover categorii -->
<script src="/js/hover.js"></script>
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="/../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="http://getbootstrap.com/assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
Now in database i have two rows id of the post and the row named text where is stored the HTML of all the page
Here is an example with content existing in row['text']
<p class='style-title'>HERE IS THE THE TEXT I WANT TO PUT IT IN <title> </p>
<div class='jumbotron'>
<img class='img-responsive' src='/img/img.png'/>
</div>
<div class='row'>
<div class="col-lg-10 ">
<img class='img-responsive' src='/img/50.png' align='left' />
<p class='some-class'>Lorm ipsum</p>
Related
webdevprocess.html
[This page is used solely for the search bar at the bottom of the page. Any search term can be entered and then a search engine can be selected from the drop down menu.]
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Web Development Process</title>
<meta name="Web Development Process" content="Simple Responsive Template is a template for responsive web design. Mobile first, responsive grid layout, toggle menu, navigation bar with unlimited drop downs, responsive slideshow">
<meta name="keywords" content="">
<!-- Mobile viewport -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<!-- CSS-->
<!-- Google web fonts. You can get your own bundle at http://www.google.com/fonts. Don't forget to update the CSS accordingly!-->
<link href='http://fonts.googleapis.com/css?family=Droid+Serif|Ubuntu' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="js/flexslider/flexslider.css">
<link rel="stylesheet" href="css/basic-style.css">
<!-- end CSS-->
<!-- JS-->
<script src="js/libs/modernizr-2.6.2.min.js"></script>
<script type="text/javascript" src="mypiechart.js"></script>
<script type="text/javascript" src="canvasjs.min.js"></script>
<!-- end JS-->
</head>
<body>
<body id="home">
<!-- header area -->
<header class="wrapper clearfix">
<div id="banner">
<div id="logo"><img src="images/logo.jpg" alt="logo"></div>
</div>
<!-- main navigation -->
<nav id="topnav" role="navigation">
<div class="menu-toggle">Menu</div>
<ul class="srt-menu" id="menu-main-navigation">
<li class="current">Home page</li>
<!-- <li>Internal page demo</li> -->
<li>Client/Server Technology
<ul>
<li>
Client/Server Technology
</li>
<li>Domain Names and Hosting</li>
</ul>
</li>
<li>
JavaScript Pages
<ul>
<li>Web Development Process</li>
</ul>
</li>
<li>
PHP Pages
</li>
</ul>
</nav><!-- end main navigation -->
</header><!-- end header -->
<!-- main content area -->
<div id="main" class="wrapper">
<!-- content area -->
<section id="content" class="wide-content">
<div class="row">
<h1>What Is The Web Development Process?</h1>
<p>A web development process,or web design and development process, is a systematic process or methodology, used tp desgn and build web sites. Just as planing goes into the design
of cars, buildings, or homes, so too is the planning and design and development process required for web sites. A good process helps ensure customer requirements are delivered in a quality
, timely and cos-effective manner.</p>
<h1>SDLC and Project Management</h1>
<p>The web design and development process can be thought of as a type of software development life cycle (SDLC) and project management methodology. The waterfall model depicted
below is a long-standing, traditional SDLC that is characterized by sequential steps. Agile is a newer method that is intended to more quickly respond to changing customer and
product requirements using an incremental process with frequent releases and customer feedback.</p>
<h3>Traditional Waterfall SDLC Methodology (PNG image)</h3>
<p><img src="waterfall.png" alt="Waterfall SDLC"></p>
<p>Source: WikiPedia</p>
<h3>Agile Methodology (GIF image)</h3>
<p><img src="images/agile.png" alt="Agile Methodology"></p>
<h3>Web Development Phases (HTML/JavaScript image)</h3>
<div id="chartContainer" style="height: 450px; width: 95%;"></div>
<script>
window.onload = function() {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title: {
text: "Web Development Process"
},
data: [{
type: "pie",
startAngle: 240,
yValueFormatString: "##0.00\"%\"",
indexLabel: "{label} {y}",
dataPoints: [
{y: 20.00 , label: "Testing"},
{y: 10.00, label: "Promotion"},
{y: 25.00, label: "Analysis"},
{y: 20.00, label: "Design"},
{y: 25.00, label: "Construction"}
]
}]
});
chart.render();
}
</script>
<br>
<form action="search.php" method="get">
<table>
<tr>
<th colspan="2">Search Sites</th>
</tr>
<tr>
<td>Site to Search:</td>
<td>
<select name="site">
<option value="google">Google Web
<option value="googlei">Google Images
<option value="duck">DuckDuckGo
<option value="wiki">WikiPedia
</select>
</td>
</tr>
<tr>
<td>Search term(s):</td>
<td>
<input type="text" name="terms" size="25" maxlength="25">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit" class-"centercell">
</td>
</tr>
</table>
</form>
<br>
</div><!-- end row -->
</section><!-- end content area -->
</div><!-- #end div #main .wrapper -->
<!-- footer area -->
<footer>
<div id="colophon" class="wrapper clearfix">
Author: Janae Roland
</div>
<!--You can NOT remove this attribution statement from any page, unless you get the permission from prowebdesign.ro--><div id="attribution" class="wrapper clearfix" style="color:#666; font-size:11px;">Site built with Simple Responsive Template by Prowebdesign.ro</div><!--end attribution-->
</footer><!-- #end footer area -->
<!-- jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.9.0.min.js">\x3C/script>')</script>
<script defer src="js/flexslider/jquery.flexslider-min.js"></script>
<!-- fire ups - read this file! -->
<script src="js/main.js"></script>
</body>
</html>
search.php
[This program is supposed to send the search terms entered to large search engines (google,google images,duck duck go,wikipedia) but I am receiving a syntax error, "
Notice: Use of undefined constant FIlTER_SANITIZE_STRING - assumed 'FIlTER_SANITIZE_STRING' in /home/jsroland/public_html/search.php on line 13
Warning: filter_input() expects parameter 3 to be long, string given in /home/jsroland/public_html/search.php on line 13"]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="Rock,Paper,Scissors">
<meta name="description" content="A function that sends data to large search engines,through the WebDev search bar.">
<link rel="stylesheet" href="style.css" type="text/css">
<title>Search</title>
</head>
<body>
<?php
$site = substr(filter_input(INPUT_GET, 'site', FIlTER_SANITIZE_STRING),0,8);
$terms = substr(filter_input(INPUT_GET, 'terms', FILTER_SANITIZE_STRING),0,25);
if ($site == "google")
header('Location: http://www.google.com/#g=' . $terms);
else if ($site == "googlei")
header('Location: http://www.google.com/search?tbm=isch&g=' . $terms);
else if ($site == "duck")
header('Location: https://duckduckgo.com/?q=&ia=web' . $terms);
else if ($site == "wiki")
header('Location: https://en.wikipedia.org/wiki/' . $terms);
?>
</body>
</html>
The minimal correct urls for search engines would be as follows:
for general Google search: https://www.google.com/search?q='<search
terms>',
for Google image search:
https://www.google.com/search?tbm=isch&q='<search terms>',
for
DuckDuckGo: https://duckduckgo.com/?ia=web&q='<search terms>',
for
Wikipedia: https://en.wikipedia.org/wiki/<search terms>.
where <search terms> are the terms to search for.
Please also mind quotation marks in the first three cases. The final code would look something like this.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="keywords" content="Rock,Paper,Scissors">
<meta name="description" content="A function that sends data to large search engines,through the WebDev search bar.">
<link rel="stylesheet" href="style.css" type="text/css">
<title>Search</title>
</head>
<body>
<?php
$site = substr(filter_input(INPUT_GET, 'site', FIlTER_SANITIZE_STRING),0,8);
$terms = substr(filter_input(INPUT_GET, 'terms', FILTER_SANITIZE_STRING),0,25);
if ($site == "google")
header("Location: https://www.google.com/search?q='$terms'");
else if ($site == "googlei")
header("https://www.google.com/search?tbm=isch&q='$terms'");
else if ($site == "duck")
header("Location: https://duckduckgo.com/?ia=web&q='$terms'");
else if ($site == "wiki")
header("Location: https://en.wikipedia.org/wiki/$terms");
?>
</body>
</html>
Hey i don't understand my website doesn't work i have don't do anything so i will explain
I got a 0 in top on my page now!
Google Chrome Explorator:Screenshot
https://validator.w3.org/nu/?doc=http%3A%2F%2Fwww.wisementrade.com%2F
View/header.php: https://pastebin.com/7GqFYR75
View/homepage.php: https://pastebin.com/3htmFSmw
View/footer.php: https://pastebin.com/b3X9KScg
Controller/View.php: https://pastebin.com/cxCdcdEQ
Chrome viewer code: https://pastebin.com/Q8VYja5u
I have check the encode UTF-8 and i have re encode UTF-8 with my sublime text but nothing change ... please need help
EDIT: FIXED
I guess unclosed HTML tag cause this problerm. I found a few unclosed HTML tag in your View/header.php. Close it. try this.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!--o-->
<?php
//Session
$customer_id = $this->session->userdata('customer_id');
$user_type = $this->session->userdata('user_type');
$statement = $this->session->userdata('timezone');
?>
<!--o-->
<link rel="icon" type="image/png" href="<?php echo base_url('images/favicon.png'); ?>" />
<meta name="author" content="Wise Men Trade" />
<meta name="copyright" content="Copyright Notice ©2015 WisemenTrade Limited and licensors. All rights reserved." />
<meta name="robots" content="all" />
<!--o-->
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script language="JavaScript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Bootstrap CSS -->
<link href="<?php echo base_url("css/bootstrap.min.css"); ?>" rel="stylesheet"/>
<!-- Basic CSS -->
<link href="<?php echo base_url("css/style.css"); ?>" rel="stylesheet"/>
<!-- Responsive CSS -->
<link href="<?php echo base_url("css/responsive.css"); ?>" rel="stylesheet"/>
<!-- Important Owl stylesheet -->
<link rel="stylesheet" href="<?php echo base_url("css/owl-carousel/owl.carousel.css"); ?>"/>
<!-- Default Theme -->
<link rel="stylesheet" href="<?php echo base_url("css/owl-carousel/owl.theme.css"); ?>"/>
<!-- MS DROP DOWN -->
<link rel="stylesheet" href="<?php echo base_url('css/msdropdown/flags.css'); ?>"/>
<link rel="stylesheet" href="<?php echo base_url('css/msdropdown/dd.css'); ?>"/>
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-62333409-1', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
</head>
<body>
<!--top-header-->
<header>
<div class="header_block">
<!-- left -->
<div class="block_left">
<a href="<?php echo base_url(); ?>">
<img src="<?php echo base_url("images/log_wmt.png"); ?>" class="logo" width="130" height="130" alt="Logo Wise Men Trade" />
</a>
</div>
</div>
</header>
also in your Controller/View.php have a few unclosed div (<div id="container"> and <div class="block_content">). check it and close it.
the last, make sure at the end of your Controller/View.php have a :
</body> <!-- end of body -->
</html> <!-- end of html -->
According to the documentation (https://www.codeigniter.com/user_guide/general/views.html), you could load multiple views in your controller, I think it doesn't work if you load it in the view, so you should have something like this:
<?php
class Page extends CI_Controller {
public function index()
{
$data['page_title'] = 'Your title';
$this->load->view('header');
$this->load->view('menu');
$this->load->view('content', $data);
$this->load->view('footer');
}
}
I am trying to create a collapsible div (using the jQuery Mobile feature) using the data from a MYSQL database. The collapsible styles are not being applied and i cant figure out what the problem is?
possible the php script?
here's what i have
page.html
<html>
<head>
<title>My App</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes">
<!-- css files -->
<!--BoilerPlate-->
<link href="css/normalize.css" rel="stylesheet" type="text/css" />
<!--<link href="css/main.css" rel="stylesheet" type="text/css" />-->
<!--end boilerplate styles-->
<!--my custom css-->
<link href="css/mainstyles.css" rel="stylesheet" type="text/css" />
<link href="css/buttons.css" rel="stylesheet" type="text/css" />
<!-- jQuery mobile js/css -->
<script src="js/jquery-3.1.1.js" type="text/javascript"></script>
<link href="js/jquery.mobile-1.4.5.css" rel="stylesheet" type="text/css" />
<!-- end of custom styles -->
<!-- END css declaration -->
</head>
<body>
<div id="canvasArea"></div>
<canvas id="cnvChart"></canvas>
<!-- JAVASCRIPT Libraries -->
<script src="chart.js/Chart.js" type="text/javascript"></script>
<script src="js/lineGraph.js" type="text/javascript"></script>
<script src="js/jquery-3.1.1.js" type="text/javascript"></script>
<script src="js/jquery.mobile-1.4.5.js" type="text/javascript"></script>
<script>
// Listen for orientation changes
window.addEventListener("orientationchange", function () {
location.reload(true);
// Announce the new orientation number
}, false);
var canvasAreaDiv = document.getElementById(
'canvasArea');
if(window.innerHeight > window.innerWidth) {
//portrait mode, so show the php script!
$(canvasAreaDiv).load("php/reflective-notes.php");
}
else {
//show the graph
showGraph();
}
</script>
</body>
script.php
$username = $_SESSION['username'];
$reflectiveMessageQuery = "SELECT date, notes FROM table WHERE
userName = '$username'";
$result = mysqli_query($conn, $reflectiveMessageQuery) or die(mysqli_error());
$count = mysqli_num_rows($result);
$rowCount = 0;
while ($row = mysqli_fetch_array($result)) {
$date = $row['date'];
$note = $row['notes'];
if($note === NULL){
$note = "no notes...";
}
echo'<div data-role="collapsible"><h1>'. $date . '</h1> <p>'.$note.'</p>'
.'</div>';
}
?>
I'm converting a couple sites from HTML to PHP for dynamic elements and have been able to do so with the header and footer (using php include()). However, I'm confused on how to do the head section. This is what I have with plain HTML:
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
<meta charset="UTF-8" />
<meta name="description" content="Liberty Resource Directory. The ultimate curated directory to find what you need."/>
<meta name="keywords" content="ethan glover, lrd, liberty resource directory"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="stylesheets/lrdstylesheet.css" rel="stylesheet" media="screen">
<title>Liberty Resource Directory</title>
</head>
I can easily add the HTML5Shim script, meta charset, viewport (yes I will remove that max scale), and the stylesheet link.
Here's the problem:
How can I write the .php file in a way that I can pass an individual pages description, keywords and title to it? (That way I can put the entire above code in a php file and just include it on every page.)
Or will I simply have to exclude the description, keywords and title, and rewrite those parts every time?
Here's the answer: (Courtesy of Alejandro Arbiza)
head.php
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
<meta charset="UTF-8" />
<meta name="description" content="<?php echo $description;?>"/>
<meta name="keywords" content="<?php echo $keywords;?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../stylesheets/lrdstylesheet.css" rel="stylesheet" media="screen">
<title><?php echo $title;?></title>
</head>
index.html (to include above code)
<?php
$description="Liberty Resource Directory. The ultimate curated directory to find what you need.";
$keywords="ethan glover, lrd, liberty resource directory";
$title="Liberty Resource Directory";
include 'scripts/head.php';
?>
The final result:
http://libertyresourcedirectory.com/
You can use variables for the description and the keywords (or anything else you want for that matter). Then, when the time comes to construct the page, you would just set the variables with the corresponding values.
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
<meta charset="UTF-8" />
<meta name="description" content="<?php echo $description; ?>"/>
<meta name="keywords" content="<?php echo $keywords; ?>"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="stylesheets/lrdstylesheet.css" rel="stylesheet" media="screen">
<title>Liberty Resource Directory</title>
</head>
So, lets say you have page1.php and page2.php:
<?php
// page1.php
$description = "This is page one";
$keywords = "page one";
include 'header.php';
?>
<!-- Page content -->
<?php include 'footer.php'; ?>
and
<?php
// page2.php
$description = "This is page two";
$keywords = "page two";
include 'header.php';
?>
<!-- Page content -->
<?php include 'footer.php'; ?>
Of course, I am assuming here that the whole HTML header is inside the header.php file, that is including <html>, <head> and <body>.
Hi i had an issue reported for my script (https://github.com/joshf/Indication/issues/6) about echo statements printing rather than excecuting
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Indication</title>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="resources/bootstrap/css/bootstrap.css" type="text/css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
}
</style>
<link href="resources/bootstrap/css/bootstrap-responsive.css" type="text/css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<!-- Nav start -->
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="#">Indication</a>
</div>
</div>
</div>
<!-- Nav end -->
<!-- Content start -->
<div class="container">
<div class="page-header">
<h1><? echo WEBSITE; ?></h1>
</div>
<div class="alert alert-error"><h4 class="alert-heading">Error</h4><p>ID cannot be blank.</p><p><a class="btn btn-danger" href="javascript:history.go(-1)">Go Back</a></p></div></div></body></html>
Notice the echo WEBSITE
The PHP code is
die("<div class=\"alert alert-error\"><h4 class=\"alert-heading\">Error</h4><p>ID does not exist.</p><p><a class=\"btn btn-danger\" href=\"javascript:history.go(-1)\">Go Back</a></p></div></div></body></html>");
!
Is this a code issue or a configuration issue, im unable to reproduce it
This is probably because you are using php short tag <?..?>. Please avoid using them and switch to long one <?php....?>
Probably you have turned off short tags in the server.
It is not a good idea to use
<? /* something */ ?>
<?=echo $something;?>
Because in some servers short tags are disabled.
Try:
<?php echo WEBSITE; ?>