PHP - Navigation In Php - Advice Needed Please
I am relatively new to PHP, trying to learn more every day.
I have been enjoying using Server Side Includes in my sidebars, footer etc with good results, much handier and more efficient! I would like to do the same for the header and main site navigation. However, the main problem that I am not sure how to deal with comes from having 'active' links (differently coloured menu tab for the page the user is on) in my menu. Here is a small menu example: Code: [Select] <div class="menu"> <ul> <li><a href="nav.php" class="active">Home</a></li> <li><a href="nav2.php">About</a></li> <li><a href="products1.php">Products</a></li> <li><a href="products2.php">Products 2</a></li> <li><a href="products3.php">Products 3</a></li> </ul> </div> When the user is on the Home page, the class is set to active - i.e. a different colour. If I do a simple server side include with my navigation this will of course be across all the pages. Can anyone please advise on what I need to do to make the menu work correctly across all the pages? (have different tabs selected for each respective page). Any help / insight is much appreciated. Similar TutorialsChapter 2 homework is coded. It works and that is the main thing, but I dont just want the grade, I want want to learn php and be proficent at it. Is there anything that looks wrong, Variable names, lack off comments, things out of place. All advice is welcome.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "html://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Temperature Conversion</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Fahrenheit to Celsius Conversions</h1> <article> <?php $degFahrenheit = 0; function degreeConverter ($degFahrenheit) { //Function converts F* to C* $degCelsius = (($degFahrenheit - 32) * 5/9); $returnCelsius = round ($degCelsius, 1); return $returnCelsius; } do {//begining of loop $convertCelsius = degreeConverter($degFahrenheit); echo "<p>$degFahrenheit degrees Fahrenheit = $convertCelsius degrees Celsius.</p>"; ++degFahrenheit; } while ($degFahrenheit <= 100);//end of loop ?> </article> </body> </html> Hello everyone. I have been told that PHP, javascript and html would be needed for this. So I am here to explain and ask your advice. Since being severely disabled in a car accident, I am trying to make use of what I have left. I would like to use my knowledge and try to help those who want to get back to work. I will give my time for free but the cost of using council premises must be paid for, albeit heavily subsedised by the benefits department. I will need a single page. It will need a datepicker (so I am told) where students can see what days are available and then select their chosen dates and complete their details. Then, the system will make some calculations and send me an email with the details that I can add to official paperwork and email on, to the student, the benefits department and the local council. I would also like to be able to "log in" to the page, to put the details in myself and still to send me the email with the details, as before. Should I explain everything I am trying to achieve, in one post, or can someone advise me as to which parts need which code and make separate posts in the corresponding threads? I am trying to study as much as possible and am finding this forum a great help. But, a little help or guidance in the right direction would be great. Thank you, in advance, for your help Hello Everyone, I want to create my own Mafia game such as, "Infamous Gangsters" have i come to the right place Basically im new to PHP coding and i want to know a list of things before i start to learn 1.) Does it cost to create a website such as: Infamousgangsters.com? 2.) How long does it take to learn PHP coding before i have enough experience to create one? 3) Does anyone have any useful documents on PHP coding which i can read to learn basic knowledge? Many Thanks, Providence I am after some advice about doing some rather basic things that wouldnt really be done in OOP and see if there's a better way of doing this. As I just said though I know this is not the required system just one displaying of a form but I think its really cool for just simplying OOP ( ), and I actually understand it, I always need to start off small, understand it all, before I start waffling will show you my code (in no way finished yet, as you can tell from some of the html elements but its principle works: <?php ini_set('display_errors',1); class Form{ public $to; public $user; public $email; public $subject; public $comment; function showForm(){ // displaying of form to the user: echo <<<userform <html> <head> <title>Jez's Contact Form</title> </head> <body> <form id="contact" name="contact" method="post" action="{$_SERVER['PHP_SELF']}"> <label for="">Enter something:</label><input type="text" id="user" </form> </body> </html> userform; } } if(!array_key_exists('submit',$_POST)) { $myForm = new Form; // now we construct the form: $myForm->showForm(); // print_r($myForm); } ?> If a submit button in the form hasnt been hit, then show form, later on going to do and try out some validation, just wanted some advice before I get too big for my boots as such. Any advice on improving it (obviously finishing my form off of course which is what I will do), but any further advice is greatly appreciated, Jez. I'm having a mini application developed to create A4 PDF's using PHP A key part of the project needs to be able to insert high quality graphics into the document that when printed out look really sharp Some of the graphics are variable and don't always have to be printed I just wanted to know if there was a general guide on what graphics and quality to use? The graphics I need printed print really well when put into a Word document at 300 resolution - so I can't see why there should be any problems inserting into a PDF - these graphics are PNG ones Unfortunately, if I insert the same PNG format into the PDF via the PHP code, the graphic turns out to be REALLY big Just looking for advice Thanks OM I am creating a site to display some products. For ease of updating I want it to run off a MySQL database. I have created the database and php scripts to output and input data etc. I know want to show that data in my web pages. My question is.... Is it best to insert HTML into the php output script to display the information and make the site look how I want....OR ....... should I create a template of the site in HTML and then somehow call the php output script (and the particular row of the database...) Basically... should I put the html code into the php - OR - put the php into the HTML?? I hope this make sense...... thanks hello. i have a navigation which i downloaded from Code: [Select] http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-bullet.htm and i would link to pull the information in from my db this is the html Code: [Select] <div class="arrowlistmenu"> <h3 class="menuheader expandable">title</h3> <ul class="categoryitems"> <li><a href="#">link</a></li> </ul> <h3 class="menuheader expandable">title</h3> <ul class="categoryitems"> <li><a href="#">link</a></li> <li><a href="#" class="subexpandable">nested title</a> <ul class="subcategoryitems" style="margin-left: 15px"> <li><a href="#">title</a></li> </ul> </li> <li><a href="#">title</a></li> </ul> <div> </div> in the database each link and title have there own parent id and level id so for example: $level $parent_id $title $link $url Hi, I am am looking to develop further the code below. This code allows me to display a left navigation bar with Main Links and then if you click a Main link, that link is listed first in the list and its' submenu appears below. For the majority of links in the navigation bar this is fine. But for about 2 of the Main links this basic navigation is not suitable. I need the navigation for 2 of the links to offer more depth. So, for example, if you click Accessories in: Shoes Trousers Shirts Accessories Looks like this if Accessories is clicked: Accessories Belts Cuff Links Wallets Shoes Trousers Shirts Looks like this if belts is clicked (Main link name changed and submenu changed): Accessories - Belts Brown leather Black Leather Multicolour Designs All casual All formal Shoes Trousers Shirts Looks like this is Brown Leather is clicked: Brown Leather Belts Armani Brown Leather Belt 32" Armani Brown Leather Belt 34" Hugo Boss Brown Leather Belt 32" Hugo Boss Brown Leather Belt 34" Shoes Trousers Shirts Currently the code does not allow for this depth in the navigation bar. Any ideas how it could be done? Do I need additional tables for each subcategory. How do I ensure the category clicked does not appear in the rest of the navigation bar, as in the code I have at the moment? Currently the code is: $res = mysql_query("SELECT * FROM categories"); while($row = mysql_fetch_array($res)) { $cats[$row['categoryid']] = $row['categoryname']; } if(isset($_GET['category'])) { $selcat = $_GET['category']; } if(isset($_GET['product'])) { $prod_info = mysql_fetch_array(mysql_query("SELECT * FROM products WHERE productid = ".$_GET['product'])); //Prod_Info now gets stored for use in the main display. $selcat = $prod_info['categoryid']; } if(isset($selcat)) { echo "<a href='categorylist.php?category=".$selcat."'>".$cats[$selcat]."</a>"; unset($cats[$selcat]); //Gets rid of it for later. $res = mysql_query("SELECT productid,name FROM products WHERE categoryid = ".$selcat); while($row = mysql_fetch_array($res)) { echo "<a href='product.php?product=".$row['productid']."'>".$row['name']."</a>"; } } foreach($cats AS $key => $cat) { echo "<a href='categoryview.php?category=".$key."'>".$cat."</a>"; } Thank you for looking at this post, Matt. So here's my problem I'm not sure how to approach this: I have a table with user_items which are stored together separated by commas. Code: [Select] 13,12,11,9,27,15,16,22,21,23,24,26,29,30,31,32,33 Now, I have a script where the user is in a trade and I want to verify the item they are trying to trade, but is there an alternative other than grabbing all of that users' items and checking that one item with all of the records? I've tried using Code: [Select] SELECT * FROM MYTABLE WHERE user_item_id IN(33) As an example to see if it will pull the rows with that ID. It didn't seem to work, am I doing it wrong? if so, forgive me. Any suggestions/help? The main problem is I don't want to have to explode that data and use a foreach to check that one item against all of that users items, as they could have well over 500. Hi, basically i have data in my database i want to represent as cash, i currently put the dollar sign infront of each echo which is fine, but how would i go about adding , to the php code itself as you cannot do this from the sql database.. In short i want to use the following code below, when someone selects there option and submits it, it would bring up details from the database on this user from the selected table, can you explain what it would be called doing this so i can look it up, Sorry to be a pain, Cheers. Code: [Select] <select name="target2" id="target2"> <option value=""></option> <?php $sql = "SELECT player_id, friend_id, name, is_active FROM contacts as c JOIN players as p ON c.friend_id = p.id WHERE c.player_id = $playerID AND is_active = 1 ORDER BY name ASC"; $que = mysql_query($sql) or die(mysql_error()); while($list = mysql_fetch_array($que)) { ?> <option value="<?php echo $list['friend_id'] ?>"><?php echo $list['name'] ?></option> <?php } ?> </select> for those of you who don't know i am creating a piece of forum software called ASF. Ive done it by myself so far but as it grows i find it harder to write the code and keep organised. my code is a mess and things arent done the way they should be. So if anyone can give me advice or wants to help i could post some of the files for download. Even if you just want to have a look and let me know waht you think. Thanks Carl http://www.thevault.cz.cc Right now I have a SESSION so when users flip though pages they carry their info with them, what I'm trying to do now is that userhome.php can't be accesses unless the user just was succesful in cracking there system.. game I'm creating for those of you helping and following me while I do this! it's a virutal hacking simulation and where I'm now is that the user's passwordcracker was compared to the target systems 'systemkey' and either granted him access or didn't, if it did it displayed a progress bar then fowarded to userhome.php where the target users info will lay, right now though if I just type in userhome.php i get there without haveing the crack it.... any ideas? Hi all, I am looking as a pet project to develop a review site, with the info stored in a database by id and the information grabbed bet get id and then displayed on a dynamic page, eg review.php?id=1 My question is this, if i throw keywords into the mix for each review, will search engines cache a review like this? Or would I need static pages for google etc to find the info? Thanks Hello, can someone please advice me on what scripts I will need to accomplish the following. I want users to be able to login to their personal page, on there will be items such as pdf files, jpeg files etc, that they will be able to download. Are there any free scripts out there that can do this, that anyone knows of? I don't mind paying if its a cheapish script for one of you to make for me, but money is a bit tight at the moment so a free script would be my 1st choice... Thanks for all your help Hi All, I currently have a ticketqueue that show's all tickets assigned to a group of people, but split into personal queues, but the way that I wrote it, means that it needs manually updating if a specific person leaves/joins the department. For example, to get the queue details, I use the following query: Code: [Select] $username1 = mssql_query("select id,subject,body,priority from queue where assignedto = username1";) $username2 = mssql_query("select id,subject,body,priority from queue where assignedto = username2";) I have repeated this code for all of the users in our team. Which seams a waste, as I have all the information on our team stored in a DB called "sysadminusers". Is there an array I could use that would look at all the usernames in the table, and then repeat the query for me? I would also need this array to display the results on the page, currently I use the following: Code: [Select] while($username1_tickets = mssql_fetch_assoc($username1)){ echo $username1_tickets['id'],$username1_tickets['subject']$username1_tickets['body'],$username1_tickets['priority'];} while($username2_tickets = mssql_fetch_assoc($username2)){ echo $username2_tickets['id'],$username2_tickets['subject']$username2_tickets['body'],$username2_tickets['priority'];} I am just looking for some design advice and code examples that would help me tidy up my code for this page, it seams a lot of code for quite a simple page. Thanks Matt hello i need someone to take a look on this , General comments on the code process and how should i continue !!! [attachment deleted by admin] I am working on adding security to my code. This is new to me and I am confused at which one to use. The numbers, email and pswd are all explanatory its the text fields that are confusing me. So I have a variety of text fields where the user can input what they want. I want to be able to add in a variety of characters but want it to be secure as well. I want to be able to use the "&" so I think I want Quote FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_AMP All the text fields will be used for descriptions or notes. Also, how secure, if at all, is this function? It was a very earlier attempt at security function check_input($data) { $data = trim($data); $data = htmlspecialchars($data); return $data; } I have made a small class to learn how to do them. This basically adds the new user to the database upon registration. I would like to know if i am doing things right or if there is a better way. Also can anyone tell me why i would use this class? Previously I just included the insert query and if statements in my main register.php page and everything worked fine. what are the advantages to using it in a class? Here is the class: <?php define ("NO_USERNAME", "Please Enter A Username"); define ("NO_PASSWORD", "Please Enter A Password"); define ("NO_EMAIL", "Please Enter An Email Address"); define ("SUCCESFULL_REGISTRATION", "Done"); define ("NO_MATCH", "Your Passwords Did Not Match"); define ("UNKNOWN_ERROR", "An Unknown Error Occured"); class User { public $user_name; public $password; public $email_address; public $password_confirm; public $processed; public $error; function user_create($user_name, $password, $email_address, $password_confirm) { if (empty($user_name)) { $this->error = NO_USERNAME; } elseif (empty($password)) { $this->error = NO_PASSWORD; } elseif (empty($email_address)) { $this->error = NO_EMAIL; } elseif ($password != $password_confirm) { $this->error = NO_MATCH; } else { $this->error = NULL; } if ($this->error == NULL) { echo "Username: " . $user_name . "<br />"; mysql_query("INSERT INTO test_members (user_name, password, email_address) VALUES ('$user_name', '".md5($password)."', '$email_address')") or trigger_error("SQL", E_USER_ERROR); $this->processed = TRUE; } } public function encryptPassword($password) { $password = sha1(md5(md5(sha1(sha1($this->password))))); } } ?> Hi, Is anyone here familiar with the Facebook API? My boss wants people to be able to share their store with their friends on Facebook from within the stores admin panel. He wants the following. 1) Display all friends with a checkbox next to each name. 2) Check the friends you want to inform about your store. 3) Post a message on checked friends wall. It sounds simple. The problem is the friends selection screen. Some of my friends on Facebook have 1000 friends. Obviously listing all of them is inpractical. Ideally I need a search box to limit the friends that display and make it easy to find who you are looking for. Does something like this already exist? Does it have a name? |