PHP - Using Get To Display Universal Content On One Page Only
Most of the websites I have built have not been large and not dynamic in nature, but I need to make one now with a boatload of content on it. and I’m needing a little resource help where I can research something. I’m sure all developers do this, and I know I need a massive database or 2 and the PHP knowledge I already have, but I’m just looking for a little guidance about how to do this the easiest way. It may actually sound like a stupid question and I might be over-thinking a bit. So… Lets say I have 500 articles that I want to make available to a site visitor and give them the option to choose what they want to look at through nav menus and submenus. I want the same page to display to the user, regardless of what article is chosen. how does PHP play a part in that? Would I be right by saying the following? If the home page had this content on it: This website is a course in PHP coding. <a href="courseTemplate.php" target="_blank">Click here</a> to view course #1. and I wanted all the course content to be displayed through the use of the “courseTemplate.php” file, how simple is that? I would assume that these types of things would be the results and the techniques to accomplish the goal, right? => a resulting URL that looks like this: www.site.com/courseTemplate.php?id=1 => storing all the text of the course material in one single field of a DB record. NOT storing the layout-oriented code (HTML, etc.) and echoing it out with the rest of the text. => making use of the GET() function somehow to pull the course’s text content out of the database. Can someone show me a website that demonstrates this? I don’t think this is very difficult, and I’m sure there are web resources available that show how this is done. I’m almost sure that most news agency websites do this, and I know for a fact that most forum software has this template technique written into it, regardless if SEO is included or not. Sorry for the basic nature of this question. I know some of my previous posts have been such where I’ve asked much more difficult questions than this. I have seen youtube tutorials on issues similar to this, but nothing pulled up by google really shows this in a very simplistic nature. thanks. Similar Tutorialshey @requinix, I know you and I have talked about this before but I just want to clarify this issue. Sadly, I have produced very few websites that have made use of dynamics in the form of database querying. But, the next project that I'm looking at will require it. The last thing I did with a query string involved the recording of downloads of file on a website. and on the page, I had this code: The archive is located he <a href="dl.php?f=archive.zip">archive.zip</a> and the ''dl'' page had this code: if(!$_GET['f']) error('Missing parameter!'); $stmt = $conn->prepare("INSERT INTO tblDownloads (ip, file, date, time) VALUES (?, ?, ?, ?)"); $stmt->bind_param("ssss", $ip, $file, $date, $time); $stmt->execute(); $stmt->close(); $conn->close(); header("Location: archive.zip"); exit; and all the variables in the above ''dl'' page are declared in a file that is required by it, called ""conn.php"". My question for anyone here is: I am going to be producing a website similar to the testing site called ""jsFiddle"": https://jsfiddle.net/ . And it is slated to have a huge amount of content on it. for example, a main page might have 100 links on it whereby, if a user clicks on any of them, it should take them to another page (or load async content) that illustrates and example of any given issue being asked about. So, I know we've talked about $_GET before Requinix, and how most websites use it to produce dynamic content. And we've also talked about the concept of markdown. But once again, can someone here remind me....what's the best way to go about doing this? Storing the actual ""answer to the issue"" content in a backend database and pulling/displaying it appropriately, kind of like what I am showing I did with the file in the above code? thanks. Adam Edited September 6, 2020 by ajetrumpetI'm new to PHP (I've done some of the basic stuff, but I'm far from anything too advanced). I'm looking to make a site with some Universal (not user specific) variables which can be configured in a control panel, but I just don't know where to begin. To give an example of what I'm looking to do: In the header.php, for instance, I'd like to allow the admin an option to display either the company logo (png) or the company name in text format. They would chose which of the two options they want (and fill out what the "company name" should be) in a separate config.php page. So, in essence, I suppose what I'm asking is "1) How do I make a configuration form store data indefinitely? 2) How do I make other pages reference that data?" I have a boostrap conflict regarding box sizing. I solved it with a simple CSS rule:
* { box-sizing: content-box; }Now the problem is my bootstrap form isn't working. I need to make the box sizing apply to everything except the bootstrap form: <form id="contactForm" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'],ENT_QUOTES); ?>" method='post'> <!-- HTML HERE --> </form>Any ideas? Thanks. I've used a little PHP but I am not great. Is there any way to take information from a html page written in basic text and have it dynamically displayed. The content I want is found he http://www.kitco.com/texten/texten.html I want to take the information from the following chart - only Metal and Ask and create a ticker. New York Spot Price MARKET IS OPEN Will close in 2 hour 24 minutes ---------------------------------------------------------------------- Metals Bid Ask Change Low High ---------------------------------------------------------------------- Gold 1822.80 1823.80 -12.30 -0.67% 1810.70 1840.90 Silver 41.45 41.55 +0.10 +0.24% 41.08 42.15 Platinum 1844.00 1852.00 -7.00 -0.38% 1826.00 1861.00 Palladium 783.00 788.00 +10.00 +1.29% 775.00 794.00 ---------------------------------------------------------------------- So basically I would just take the word: Gold - $1823.80 Silver - $41.55 Platinum $1852.00 Palladium - $788.00 Can someone help me through this or point me in a direction where I can read more about accomplishing this? I've been searching google for articles but still haven't found what I'm looking for. nofx1728 Hi folks, I am in the middle of creating a CMS as a project. It's going pretty well so far but I am stuck and hoping to get some guidance. When loading the main website, I want the contents from "Home" in the database to display unless a menu item is clicked. Here is what I have so far: <?php include_once('includes/header.php'); require_once('admin/includes/config.php'); ?> <div class="hero-wrap" style="background-image: url('images/uluru.jpg');" data-stellar-background-ratio="0.5"> <div class="overlay"></div> <div class="container"> <div class="row no-gutters slider-text justify-content-start align-items-center"> <div class="col-lg-6 col-md-6 ftco-animate d-flex align-items-end"> <div class="text"> <h1 class="mb-4">Coaches For Hire <span>Book Now!</span></h1> <p style="font-size: 18px;">The local Anangu, the Pitjantjatjara people, call the landmark Uluṟu (Pitjantjatjara [ʊlʊɻʊ]). This word is a proper noun, with no further particular meaning in the Pitjantjatjara dialect, although it is used as a local family name by the senior Traditional Owners of Uluru.</p> <a href="https://www.youtube.com/watch?v=biuYA54nb7Y" class="icon-wrap popup-vimeo d-flex align-items-center mt-4"> <div class="icon d-flex align-items-center justify-content-center"> <span class="ion-ios-play"></span> </div> <div class="heading-title ml-5"> <span>Learn more about Uluru</span> </div> </a> </div> </div> <div class="col-lg-2 col"></div> <div class="col-lg-4 col-md-6 mt-0 mt-md-5 d-flex"> <form action="#" class="request-form ftco-animate"> <h2>Get A Quote</h2> <div id="searchBoxContainer" class="form-group"> <label for="searchBox" class="label">Pick-Up Location</label> <input class="form-control" type="text" id="searchBox" placeholder="Start Typing..." /> </div> <div id="searchBoxContainerAlt" class="form-group"> <label for="searchBoxAlt" class="label">Drop-Off Location</label> <input type="text" class="form-control" id="searchBoxAlt" placeholder="Start Typing..." /> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Departure Date</label> <input type="text" class="form-control" id="book_pick_date" placeholder="Date"> </div> <div class="form-group ml-2"> <label for="" class="label">Return Date</label> <input type="text" class="form-control" id="book_off_date" placeholder="Date"> </div> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Pick-Up Time</label> <input type="text" class="form-control" id="time_pick" placeholder="Time"> </div> <div class="form-group ml-2"> <label for"" class="label">Passenger Numbers</label> <input type="number" class="form-control" placeholder="Amount" /> </div> </div> <div class="form-group"> <input type="submit" value="Request Quote" class="btn btn-primary py-3 px-4"> </div> </form> </div> </div> </div> </div> <script type="text/javascript" src="https://www.bing.com/api/maps/mapcontrol?key=AqIY0ivSCCdBIe3-EKGuox9cwBFw2wWRWIErZi1iy57EfD67PoiSra9wl_wu48de&callback=bingMapsReady" async defer></script> <?php $id = $_GET['id']; $sql = "SELECT * FROM pages WHERE id = $id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_array()) { ?> <!-- HOW IT WORKS --> <section class="ftco-section ftco-no-pt ftco-no-pb"> <div class="container"> <div class="row no-gutters"> <div class="col-md-12 wrap-about py-md-5 ftco-animate"> <div class="heading-section mb-5 pl-md-5"> <span class="subheading"><?php echo $row['description']; ?> </span> <h2 class="heading"><?php echo $row['name']; ?></h2> <?php echo $row['body']; ?> </div> </div> </div> </div> </section> <?php } } ?> <!-- FOOTER --> <?php include_once('includes/footer.php'); ?> I hope you can help and that I am making sense. Cheers, Dan Edited January 9 by DanEthicalSlideshow programs created with Slideshow Maker. The html version works but opens in a new window. I want it to open in the content window same as all other programs. menu2.php (partial) <li> <a href="#">Slideshows</a> <ul> <li> <a href="index.php?page=slideshow_shed">Shed construction</a> </li> <li> <a href="content/pages/slideshow_shed.html">Shed Construction</a> </li> </ul> slideshow_shed.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Shed Pictures</title> </head> <body bgcolor="#FFFFFF"> <p> <p> <style type="text/css"> <!-- .style1 { color: #006633; font-weight: bold; } --> </style> <!-- saved from url=(0013)about:internet --> <table align="center" border="0" cellpadding=0 cellspacing=0> <tr> <td align="center">Shed Pictures</td> </tr> <tr><td align="center"><br /></td></tr> <tr> <td align="center"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="768" height="576" id="tech" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="slideshow_shed.swf" /> <param name="quality" value="high" /> <embed src="slideshow_shed.swf" quality="high" width="768" height="576" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </td> </tr> <tr> <td align="center" ><br /> Created by <a href="http://www.flash-slideshow-maker.com/index.php?srcid=glc" target="_blank">Flash Slideshow Maker</a> </td> </tr> <tr> <td align="center" valign="middle" bgcolor="#FFCC99"><br /> <a href="http://www.flash-slideshow-maker.com/buynow.php?srcid=glc" target="_blank"><strong>Order the full version now to remove the software logo at the end of slideshow</strong></a> </td> </tr> </table> </body> </html> slideshow_shed.php <?php ?> <style type="text/css"> <!-- .style1 { color: #006633; font-weight: bold; } --> </style> <table align="center" border="0" cellpadding=0 cellspacing=0> <tr> <td align="center">Shed Pictures</td> </tr> <tr><td align="center"><br /></td></tr> <tr> <td align="center"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="768" height="576" id="tech" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="slideshow_shed.swf" /> <param name="quality" value="high" /> <embed src="slideshow_shed.swf" quality="high" width="768" height="576" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </td> </tr> <tr> <td align="center" ><br /> Created by <a href="http://www.flash-slideshow-maker.com/index.php?srcid=glc" target="_blank">Flash Slideshow Maker</a> </td> </tr> <tr> <td align="center" valign="middle" bgcolor="#FFCC99"><br /> <a href="http://www.flash-slideshow-maker.com/buynow.php?srcid=glc" target="_blank"><strong>Order the full version now to remove the software logo at the end of slideshow</strong></a> </td> </tr> </table> I don't get any errors, just the title "Shed Pictures" displays. Name says it all. I have a form and 2 tables that are going to have to be linked with each other. Although what I'm trying to do now is very basic and I'm struggling haha Though this is my first php project Basicly I got a form with a drop down menu, which I want to display the contents of my table (course) which the user then selects from and submits to another table (student) Here is my code for this part <?php Code: [Select] <?php $q = "SELECT cname FROM course "; $result = mysql_query($q); $course = mysql_fetch_array($result); ?> <div id="apdiv3"> <FORM action = "demo.php" method ="post"> <p>Course name:</p> <select name="cname"> <OPTION> <?php echo $course['cname']; ?> </option> </SELECT>?> It only displays 1 item from my course table. What am I doing wrong? And also please explain so I can learn from my mistakes About a year ago I wrote a mod_rewrite in at sites htaccess file. It was to call a page that queried the database based on a unite code that was assigned to a member. If the member was assigned a code that was FL1001, the URL www.marketingteammates.com/FL1001 would bring up a page that quaried that member and displayed their database content.
In the users table of the site, it quaried the field webPageID and the information was called. It called a page webpage.php that quaried the info. The URL in the address bar still displayed www.marketingteammates.com/FL1001. Here are the lines of code in the htaccess file.
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z])([A-Za-z])([0-9]+)$ /webpage.php?webPageID=$1$2$3 [NC,L]I now have a second page completely different from the webpage.php. It is a page storeNumber.php and would query a field storeNumberID. This field could contain any kind of string such as Store#101, or mystore101, or #101 is my store. I tried using the same rewite rule just replaceing the webpage.php and variable with storeNumber.php and $storeNumberID. This doesn't work. It also leads me to wonder if there can even be two different pages in the mod_rewrite. How would it diferentiate one from the other. Thanks for any help in advance. Mike Hi every one I want to share a page content(or an article) into my facebook page via php . How should I do that ? Thanks Currently, in my files, I echo content through either a function called error() or a funtion called info(). Each function has 3 require statements for the header, body and footer files and that is all that is contained in the function. What I want to do is, if error() is called, is kind of leave the script and exit it. Surprisingly I have used exit; at the end of the functions to stop any more of the script being executed. Is this the best way of doing it? Hello. I am attempting to display content from a database to a web page. I have SELECT * etc to do this, plus the menu that should be displayed has links to pages. This would display text to the page depending on the link, for this to work I use the id of the page ($Get['id']). Following advice (not code), I have attempted the following:
<!DOCTYPE html> <html> <?php include 'includes/headsection.php'; ?> <body> <?php // query database if (!empty($_GET['id']) && (intval($_GET['id']) == $_GET['id'])) { $pdo_statement = $conn->prepare("SELECT * FROM pages WHERE id=:id ORDER BY id ASC"); $pdo_statement->execute(['id' => $_GET['id']]); $result = $pdo_statement->fetchAll(); } ?> <!-- topMenu --> <table id="topMenu"> <tr> <td><h1 class="siteName">Site name</h1></td> <td> <?php if(!empty($result)) { foreach($result as $row) { ?> <a href="index.php?id=<?php echo $row['id']; ?>"><?php echo $row['menuheader']; ?></a> <?php } } ?> </td> </tr> </table> This issue is that the top menu (home, etc), does not appear, and there are no errors to suggest what I have done wrong. Any help will be appreciated. I include a picture of what I mean. There should be Home | other | etc...
I have a php page in which javascript called like this <script language="JavaScript" type="text/javascript" src="http://www.test.com/test.php"></script> the output of the page shows a well detail table , but when i use file_get_content method to get that all detail in a varaible its just took above javascript like $a=<script language="JavaScript" type="text/javascript" src="http://www.test.com/test.php"></script> when i right click on page to view source it show just <script language="JavaScript" type="text/javascript" src="http://www.test.com/test.php"></script>. But on actual page there is a html table which detail i have to store in table, Can any one tell me method. Good day everyone! I know this is possible but I do not know how to do it. I have a single page, this page has no dynamic content. I have a set of links. What I need is to have content placed on the page based on the link the user clicks. Example: I have pictures of animals. When the user click a Zebra, the Zebra info is placed on the page. So the page does not change, meaning the content on the page changes but not the page it self. The idea is instead of creating different html pages for each animal profile, the profile is generated to the page from a php include file. Is is this possible? Can anyone, some one please point me to how I can get this going. Thanks everyone! IC http://buildmyweb.org/testing/starter/
at the link above, you can see a test-page. the problem im having is that the content in the footer gets cutoff on the right side of the footer when viewed in an ipad. id love to hear it if anyone can figure out why
here is the html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="keywords" content = "Under Construction" /> <meta name="description" content="is currently Under Construction." /> <title>Under Construction</title> <link rel="stylesheet" type="text/css" href="bmw_footer_abs.css" /> </head> <body id="page_home"> <div id="wrapper"> <div id="banner"> </div> <!-- close banner --> <div id="main"> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> </div> <!-- close main --> </div> <!-- close wrapper --> <div id="footer"> <div id="footer_content"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> <!-- close footer_content --> </div> <!-- close footer --> </body> </html>and the css: html { position: relative; min-height: 100%; } body { margin: 0 0 100px; /* bottom = footer height */ } #footer { position: absolute; left: 0; bottom: 0; height: 100px; width: 100%; min-width:1000px; background:gray; } #wrapper { position:relative; top:0px; margin:0 auto; width:1000px; text-align:left; background:pink; padding:0px; } /* **************** BANNER *************** */ #banner { float:left; background:green; width:100%; height:10px; } /* **************** MAIN *************** */ #main { float:left; width:100%; background-color:#f0f3f8; } /* **************** FOOTER *************** */ #footer { font-size:85%; line-height:1.3; } #footer_content { width:1000px; margin:0px auto; background:orange; } I'm doing a cURL post to a server and it returns "true No_Error Data was accepted 10356546 3770 false 0 " Form --> Method=Post --> submit.php (this is the page that's doing the cURL post and the server returns data that appears on this page). How do I take this and put it into a string? What I'm trying to do is get a php file with content to load into my basic page template based on the page id, however it's not loading anything, however there are no errors coming up. I've looked everywhere I could find, and tried everything I could think of. I really could use some help on this. Below is the page template code and the code I'm trying to use to get the content to load up. page_templ.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <link rel="stylesheet" type="text/css" href="templates/content/style.css" > <!--This is the css used for IE because we need to correct some things for it.--> <!--[if IE]> <style type="text/css"> @import 'templates/content/styleIE.css'; </style> <![endif]--> </head> <body> <?php //We need to load our language files with our common text varibles require("content/langeng.php"); ?> <div id="header"> <? //Lets show the header. I use html where I can so smartphones load as little advanced code as possible require_once("header.php"); ?> </div> <div id="menu"> <?//Now our menu. require_once("menu.php"); ?> </div> <div id="mbody"> <?//Now the primary site content. //Load up our postvars.php file require_once("content/postvars.php"); ?> </div> </body> </html> postvars.php Code: [Select] <?php $id = $_POST["id"]; if ( $id == "home" ) { include 'main_c.php'; } elseif ( $id == "guides" ) { include 'guides_c.php'; } elseif ( $id == "trips" ) { include 'trips_c.php'; } ?> Hello! I would like to use cURL to login to the website: lockerz.com I have some code, but it doesn't seem to work: <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auth/login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auction'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); echo $content; ?> Thank you very much if you can help! This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357949.0 Hi there, I have updated a webpage and it appears that some users are still seeing the older version of the page. Is there a way I can force the user's version of the page to display the latest content on the page? I have see I can add some meta tags which control the cache, but my site relies quite heavily on cookies, so I guess clearing the cache would reset/have an effect on the cookies? Does anyone have any ideas on how I can make users always see the latest content? Thanks! |