PHP - Keeping My Header And Footer On All Webpages Using Php?
I've finished designing my website home page and I've now moved on the some of the other pages, I want my header and footer to appear the same on every page. I've tried this basic way of linking the same stylesheet that makes up my header/footer in the second HTML file (already used in the homepage):
<link rel="stylesheet" href="footer.css" type="text/css"/>
<link rel="stylesheet" href="header.css" type="text/css"/> I now understand that this isn't going to work. Would a server-side scripting language be my best bet here? Something like PHP? If so, would anyone be able to link me with an article on how I could do this in PHP, I presume with the include function? I've had answers elsewhere but this, for me, isn't working: "You are currently only linking the css for the header and footer. If you want to include the html as the same, create two separate files header.php and footer.php, then include them into each webpage. <?php include('path/to/header.php');?> // in the location you want the header in the page <?php include('path/to/footer.php');?> // in the location you want the footer Essentially, you're making partials and placing them wherever you want them" Any help would be greatly appreciated. Edited by Coplestone, 15 January 2015 - 11:52 AM. Similar TutorialsHi
I want to get my <footer> to appear at the bottom of my page, but I dont want it to be fixed there.
So if the middle contents of a page is very short, the <footer> will be visibled at the bottom of the browser, but if the page contents is long, then the <footer> would just disappear at the bottom of the contents.
Can this be done?
Thanks
I have written a page that works perfectly on showing the data I need in question. The problem is my footer is showing up as my header... I don't know why. Can someone explain? I put it at the end of the page, after all the php code, and it seems to me it should be inserted there, but for some reason it shows on the top. If anyone can help it be greatly appreciated. Here is the page: http://kaboomlabs.com/testbed/print.php?id=1 Here is the code: Code: [Select] <?php require_once('tb/connectvars.php'); echo '<div id="printwrap">' ?> <!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>PDI NCMR - Print</title> <link rel="stylesheet" type="text/css" href="tb/postie.css" /> </head> <body> <div id="logo"> <img src="tb/PDI_Logo_2.1.gif" alt="PDI Logo" /> </div> <?php // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Grab the profile data from the database if (!isset($_GET['id'])) { $query = "SELECT * FROM ncmr WHERE id = '$id'"; } else { $query = "SELECT * FROM ncmr WHERE id = '" . $_GET['id'] . "'"; } $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The user row was found so display the user data $row = mysqli_fetch_array($data); echo'<div id="title"><h3 id="NCMR2">Non-Conforming Materials Report (NCMR: ' . $row['rma'] . ')</h3></div>'; echo '<form id="all">'; echo '<fieldset>'; //Part, Rev, Part Description, NCMR Qty echo '<div id="box1p">'; if (empty($row['ab'])) $row['ab'] = "Empty"; if (empty($row['date'])) $row['date'] = "Empty"; if (empty($row['part'])) $row['part'] = "Empty"; if (empty($row['rev'])) $row['rev'] = "Empty"; if (empty($row['partdesc'])) $row['partdesc'] = "Empty"; if (empty($row['ncmrqty'])) $row['ncmrqty'] = "Empty"; echo '<div id="abp"><span class="b">Added By: </span>' . $row['ab'] . '</div>'; echo '<div id="datep"><span class="b">Date Filed: </span>' . $row['date'] . '</div>'; echo '<div id="partp"><span class="b">Part Number: </span>' . $row['part'] . '</div>'; echo '<div id="revp"><span class="b">Part Revision: </span>' . $row['rev'] . '</div>'; echo '<div id="partdescp"><span class="b">Part Description: </span>' . $row['partdesc'] . '</div>'; echo '<div id="ncmrqtyp"><span class="b">NCMR Qty: </span>' . $row['ncmrqty'] . '</div>'; echo '</div>'; //Part, Rev, Part Description, NCMR Qty, JO, SN and INV echo '<div id="box2p">'; if (empty($row['comp'])) $row['comp'] = "Empty"; if (empty($row['ncmrid'])) $row['ncmrid'] = "Empty"; if (empty($row['rma'])) $row['rma'] = "Empty"; if (!empty($row['NCMR_Qty'])) $row['NCMR_Qty'] = "Empty"; echo '<div id="comp"><span class="b">Company: </span>' . $row['comp'] . '</div>'; echo '<div id="ncmrid"><span class="b">Customer NCMR ID: </span>' . $row['ncmrid'] . '</div>'; echo '<div id="rma"><span class="b">Internal RMA: </span>' . $row['rma'] . '</div>'; echo '<div id="jno"><span class="b">Job #: </span>' . $row['jno'] . '</div>'; echo '</div>'; //Inventory On Hand, Inventory Check, Supplier Name, Supplier Number, Manufacturer Part Number, Manufactuer Serial Number and NCMR ID echo '<div id="box3p">'; if (empty($row['fdt'])) $row['fdt'] = "Empty"; if (empty($row['cof'])) $row['cof'] = "Empty"; echo '<h2>Failures</h2>'; echo '<div id="fdt"><span class="b">Failure Due To: </span><br />' . $row['fdt'] . '</div>'; echo '<div id="cof"><span class="b">Class of Failu </span><br />' . $row['cof'] . '</div>'; echo '</div>'; //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box4p">'; if (empty($row['fab1'])) $row['fab1'] = "Empty"; if (empty($row['fab2'])) $row['Disposition'] = "Empty"; if (empty($row['fab3'])) $row['Comments'] = "Empty"; echo '<h2>Fabricators</h2>'; echo '<div id="fab1"><span class="b"></span>' . $row['fab1'] . '</div>'; echo '<div id="fab2"><span class="b"></span>' . $row['fab2'] . '</div>'; echo '<div id="fab3"><span class="b"></span>' . $row['fab3'] . '</div>'; echo '</div>'; //PO, PO Date, and Date Recieved echo '<div id="box5p">'; if (empty($row['non'])) $row['non'] ="Empty"; if (empty($row['dis'])) $row['dis'] ="Empty"; if (empty($row['comm'])) $row['comm'] ="Empty"; if (empty($row['caad'])) $row['caad'] ="Empty"; echo '<div id="non"><span class="b">Nonconformity: <br /></span>' . $row['non'] . '</div><br /><br />'; echo '<div id="dis"><span class="b">Disposition: <br /></span>' . $row['dis'] . '</div><br /><br />'; echo '<div id="comm"><span class="b">Comments: <br /></span>' . $row['comm'] . '</div><br /><br />'; echo '<div id="caad"><span class="b">Comments and/or Additional Details: <br /></span>' . $row['caad'] . '</div>'; //PO, PO Date, and Date Recieved echo '<div id="podrp">'; if (empty($row['po'])) $row['po'] ="Empty"; if (empty($row['pod'])) $row['pod'] ="Empty"; if (empty($row['dri'])) $row['dri'] ="Empty"; echo '<div id="pop"><span class="b">PO: </span>' . $row['po'] . '</div>'; echo '<div id="podp"><span class="b">PO Date: </span>' . $row['pod'] . '</div>'; echo '<div id="drip"><span class="b">Date Recieved: </span>' . $row['dri'] . '</div>'; echo '</div>'; echo '</div>'; echo '<div id="box6p">'; //NCMR Supplier Response & Comment if not empty if (empty($row['ncmrsr'])) $row['ncmrsr'] ="Empty"; if (empty($row['ncmrsc'])) $row['ncmrsc'] ="Empty"; echo '<div id="ncmrsr"><span class="b">NCMR Supplier Response:</span><br />' . $row['ncmrsr'] . '</div><br /><br />'; echo '<div id="ncmrsc"><span class="b">NCMR Supplier Comment:</span><br />' . $row['ncmrsc'] . '</div><br /><br />'; echo '</div>'; echo '</fieldset>'; echo '</div>'; echo '</form>'; } mysqli_close($dbc); echo '</div>'; require_once('tb/pfooter.php'); ?> </body> </html> I have implemented this slider http://kgperazim.com/test/film2 , however I'd like my header and footer to stay on screen whenever I'm scrolling horizontally.
What would be the best solution to do that with css?
Thx for any advice.
Ok, I would just like some advice on how to go about doing something. A website that alot of my friends use to make their builds in-game goes down frequently causing them not to be able to pull up their build information. I would like to be able to use php to copy not only the html source, but the images as well to my websvr to be able to view when their site is offline. Now I know I could simply just click page -> save as complete html in internet explorer and then upload that... However I don't want to have to do that for everyone stuff.. its time consuming.. I was hoping to automate the process with a script. I know how to get the html source from a website, but I don't know how to pull the content "pictures ect." to make it actually look like their site and have more than just text. I'll appreciate any advice you can give, I think some simple direction should be enough to get me going. Hello. I've asked around in many places now, and I thought I'd ask here too. A few days ago I installed phpBB3 on my site, works like a charm. I used a plugin for wordpress to integrate phpbb to wordpress, all works great. Now my problem is to embed the forum to my wordblog page. I tried using a simple iFrame solution, and it worked almost, but there's a common iFrame problem. The height, it doesn't scale with the embedded page, instead it stays as a 100px high frame with a scroll bar. I've searched google for hours now, and tried every possible javascript and css/div-tag solution I came across. Nothing works. Are there any alternatives to this? I tried using <?php include('../phpBB3/index.php') ?> But I get errors. It might be because I'm including from another directory, so it might be worth giving a try to give the direct path somehow, but how? Anyway, are there any other solutions for this problem? Hi All, I am a newbie to php and I have this issue. I would appreciate if anyone can help out. I tried a few things but was not able to come up with a solution. From reading few codes and learning from it, I created this function in query.php and am calling this function in uk.php file, but the problem is that it loads and shows the data in table, but then it stops loading page from there on and the footer which is in html code after the place where I am calling this function does not load. I tried removing return false; command, but with that it loads the footer, but it shows the table after the footer. I want the table with data to show in between header and footer. Can you guys let me know what I need to do to achieve that? File Name: query.php
function uk() { $output = ''; $result = db_query("SELECT * FROM lecture where groups='uk'"); if(mysqli_num_rows($result) > 0) { $output .= '<div id="style2" style="overflow-x:auto;"> <table> <tr> <th class="text-center">Date</th> <th class="text-center">Title</th> <th class="text-center">Venue</th> <th class="text-center">Duration</th> <th class="text-center">Size (MB)</th> <th class="text-center">Link</th> </tr>'; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td>'.$row["mydate"].'</td> <td>'.$row["title"].'</td> <td>'.$row["venue"].'</td> <td>'.$row["duration"].'</td> <td>'.$row["size"].'</td> <td><a href="../'.$row["path"].$row["file_name"].'">Save</a></td> </tr> '; } echo $output; } else { echo 'Data Not Found'; } }
File Name: uk.php
Header html code here Some body text <?php include '../includes/query.php'; uk(); return false; ?> Footer html code here
Hi, Where to install this PHPMailer? It is on WebServer or it will work if I install it in the same folders where my webpages are? Thanks. I'm trying to work on my php skills by creating an online content "finder". I'm using cURL to grab webpage HTML and store it in a variable. I then want my program to find the article title, keywords and the content. I'm using articles from Ezine. here is an example webpage. Code: [Select] http://ezinearticles.com/?8-Ways-to-Reduce-Stock-Investment-Risks&id=954266 I don't have any problems grabbing the webpage html. But when I try to grab the title, keywords, and content using this code. Code: [Select] $title = getbetween($html, "<title>", "</title>"); $keywords = getbetween($html, "<meta name=\"keywords\" content=\"", "\">"); $content = getbetween($html, "<div id=\"body\">", "</div>"); $content = "<P>" . getbetween($content . "<E>", "<P>", "<E>"); echo "Title: " . $title . "<P>"; echo "Keywords: " . $keywords . "<P>"; echo "Content: " . $content . "<P>"; Only the title comes out of the page, the rest of the values are blank... I'm not sure why the getbetween is only working to extract the title from the html. Does anyone have any ideas why?? I tried testing to see if it was grabbing the propper webpage and when I used 'echo $html;' the webpage came out fine on my page.. I am totally lost on this, I just want to practice using cURL and my webrequest coding. Thanks for any help, I appreciate it. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350027.0 Hello everyone, I'm just starting out with PHP as I need to create an online bookstore for a school project. I'm working by a magazine which should teach you exactly how to do this using PHP, but I've had a bunch of problems with the code they use and I don't really know what's going on. Anyway, this looks really simple and basically what it does is allows you to post a comment on a book, then returns you to the book's page. Problem is, I'm getting the Header may not contain more than a single header, new line detected. error and I can't figure out why. I've tried researching into the matter but all the cases I found had to do with returning to an url, which is not my case. Anyway, here's the snippet of code: The form: Code: [Select] <div style="width:400px; border:1px solid #ffffff; background-color:#F9F1E7; padding:5px"> <b>Adauga opinia ta:</b> <hr size="1"> <form action="adauga_comentariu.php" method="POST"> Nume: <input type="text" name="nume_utilizator"><br><br> Email: <input type="text" name="adresa_email"><br><br> Comentariu: <br> <textarea name="comentariu" cols="45"></textarea><br><br> <input type="hidden" name="id_carte" value="<?=id_carte?>"> <center><input type="submit" value="Adauga"</center> </form> </div> The script adaugare_comentariu.php: Code: [Select] <?php ob_start(); include("conectare.php"); $numeFaraTags=strip_tags($_POST['nume_utilizator']); $emailFaraTags=strip_tags($_POST['adresa_email']); $comentariuFaraTags=strip_tags($_POST['comentariu']); $sql="insert into comentarii (id_carte, nume_utilizator, adresa_email, comentariu) values(".$_POST['id_carte'].", '".$numeFaraTags."','".$emailFaraTags."','".$comentariuFaraTags."')"; mysql_query($sql); $inapoi="carte.php?id_carte=".$_POST['id_carte']; header("location:urldecode($inapoi)"); ob_end_flush(); ?> conectare.php connects to the mysql database. $inapoi is the variable which returns the user to carte.php (the book he posted a comment on), where id_carte is the book's unique id. I'm getting Header may not contain more than a single header, new line detected on line ten, which is the header line. Can anyone help me? I've been stumped on this for a few days now and I've just let it pass and started working on other bits, but it's bugging me too much and I'd like to fix it. I'm updating my database with a set of data from another database. When there is an item deleted from the source db, how would I make sure it's deleted from the db copy given that I have to run the update in a batch and can't run it when the item is deleted? Would I truncate the db at the beginning of each update, then pull all the of data over? In my Payment Form, I have an ExpMonth (e.g. '01') and ExpYear (e.g. '2011'). Each value is assigned to $expMonth and $expYear respectively. I then need to combine them and keep the format ('MMYYYY'). I am afraid that this code may truncate leading zeros... Code: [Select] $expDate = $expMonth . $expYear Will my code work, or do I need to do something else to ensure the Month stays ('MM') and the year stays ('YYYY')? Debbie Like 6 years ago I had made a forum software for me and my buddies to post on. It had worked all great until my friend had posted a character that skewed my whole database, unintentionly, he knew nothing about computers. But I really haven't dabbed in PHP since 2008, I'm just now getting back into it again. I need to know how I can make data from an input to be put into an MySQL database and not screw up my code. So something along the lines that make the code safe and not exploitable. Also any third party scripts on captcha would be great! What are the different ways you can keep a User "logged in"? From what I *vaguely* recall from a year or two ago when I read a whole hoard of PHP books, you commonly use cookies and sessions. But I'm asking this more from an OOP standpoint than a PHP standpoint. Let's say I have a User record in my database, and a User comes along and attempts to log in. In OOP terms, I would think you'd call some class to help log them in, and upon successfully logging in, you would "load" the User object into memory and set the "LoggedIn" field to "True". Then as long as that field was set in their object, they could surf all over the place and do things like change their account and buy things. Is that how you would do it in OOP? TomTees I've got a weird problem which affects only Safari browsers. Site A offers user a login page and validates the credentials by calling HTTPRequest on site B ( this call starts new session, user password is checked and session id stored in the db). If user login details are OK, site A redirects user to site B ( different domains and physical boxes). It worked well before the last Safari update (5.0.1) - when user login is being checked, server B creates session X, after the redirect, session_start() creates absolutely different session Y. All sessions are maintained by cookies only (SSL). Any ideas how to maintain the same session during the redirect? Thanks! This sounds like it should be pretty simple but I've looked for a while and I'm having trouble finding an answer. What I have is a simple table with 3 columns with predetermined widths. When the text that is queried from the database is inserted into the table, and the text string is longer than the column width, it pushes the text to a second line, which throws the whole table out of whack. Instead, I want the text to be cut off before going to the next line. For example: This is what is happening: This is a sample string of text. This is what I'm trying to do: This is a sample string... Can anyone tell me where to find the solution to this problem? Not that it's needed, but here is some simple code that I'm working with: Code: [Select] <?php $message = "This is a sample string of text."; echo "<table width=\"150\" height=\"20\"border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td width=\"50\" height=\"20\" align=\"left" valign=\"top\">Column 1</td>"; echo "<td width=\"50\" height=\"20\" align=\"left" valign=\"top\">Column 2</td>"; echo "<td width=\"50\" height=\"20\" align=\"left" valign=\"top\">$message</td>"; echo "</tr>"; echo "</table>"; ?> I am trying to take a specific link from my site and place it into my database. I only want links starts with CORPSEARCH.ENTITY_INFORMATION?p_nameid= Can someone point me in the right direction here? Code for this is below: // make the cURL request to $target_url $html= curl_exec($ch); if (!$html) { echo "<br />cURL error number:" .curl_errno($ch); echo "<br />cURL error:" . curl_error($ch); exit; } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); $sql="INSERT INTO links(cid, nlink)VALUES('$i','$url')"; $result=mysql_query($sql); echo $result; echo $url;
I need to create the unique SKU (Stock Keeping Unit) name for each products mixed with i.e.: SKU for a product with
id=13, becomes : BI-IKHA0013 This is how I tried: $inm = "Bio Clean green500ml"; $cnm = "INSECTS KILLERS"; $bnm = "HARPIC "; echo SKU_gen($inm, $cnm,$bnm,20).'<br>'; function SKU_gen($pname, $cat=null, $brand=null, $id = null, $l = 2){ $results = ''; // empty string $str1 = array_shift(explode(' ',$pname)); $str1 = strtoupper(substr($str1, 0, $l)); $str2 = array_shift(explode(' ',$cat)); $str2 = strtoupper(substr($str2, 0, $l)); $str3 = array_shift(explode(' ',$brand)); $str3 = strtoupper(substr($str3, 0, $l)); $id = str_pad($id , 4, 0, STR_PAD_LEFT); $results .= "{$str1}-{$str2}{$str3}{$id}"; return $results; } But this function is not working as expected when category of brand values become NULL. Hi Guys
I'm building a php application where users must login to access a set of private images. The images display as a set of thumbs to the user, which they can click to download the full size image. so I need to read a whole batch images (500+) of them from a directory.
So I'd like some advice on the best way to:
1) Keep files from being world readable. I know you could probably achieve this using htaccess or storing them outside the document root but which is best given that I need to read a whole directory with hundreds of images? 2) How to access the images If it turns out storing the images off document root is the way to go, what's the most efficient way to read a directory off the doc root and access the individual images (readfile for instance)? Thanks in advance, Drongo Hi all, I followed a tutorial to get the base of a php calendar done, then added some custom Javascript in order to be able to change the color of the cells. The calendar can be seen he http://www.education-world.co.uk/Education%20World%20Site/calendar.php The problem is now, that I need to integrate a SQL database to keep track of what was set for certain dates. I'm not sure of how to even begin this, all i need to do is keep track of if the candidate is available, not available or working for a specific day. The calendar is submitted to an email but this means when they return at a later date (availability may change) their previously set availability will have been wiped! I can provide code if needed. Can anyone help me out here, really struggling with this! Many thanks, Greens85 |