PHP - How To Make A Link Show That It's Active
I would like to know how to make my links show that it's active. For example if I click on a link that says overview then that link has to be highlighted.
This is the code that I have: Code: [Select] <?php if (isset($this->_params['submenus']) && is_array($this->_params['submenus'])){ foreach ($this->_params['submenus'] as $submenu){ ?> <li class="active"><a href="<?php echo $this->get_uri("/{$submenu['controller']}/{$submenu['action']}") ?>" onclick="javascript:return setSubMenu(<?php echo $submenu['id'] ?>);"><?php echo strtoupper($submenu['name'])?></a></li> <?php } } ?> Unfortunately with this code all the links are selected as active. Similar TutorialsHi, Sorry if this is in the wrong place. I really just need a search term to use for what i'm trying to do. I would like my buttons to appear pressed on each page. For example if you are on the home page the home button will appear pressed. If you are on the screenshots page the screenshots button will appear pressed. Pretty much i want my nav bar to display what page is being viewed. I'm using SMF forums and i've created an extension of my forum that i'm using on the root of my site. As far as i can tell i have the correct code added to the forum that should highlight the home button while on the home page. The part i'm missing is the code to add onto the home page. This is the code I have on the button. $buttons = array( 'overview' => array( 'title' => $txt['overview'], 'href' => 'http://www.wararmada.com', 'show' => true, 'sub_buttons' => array( 'alliance' => array( 'title' => $txt['alliance'], 'href' => $scripturl . '?action=overview;area=alliance', 'show' => true, ), This is the code i have in the language file. $txt['overview'] = 'overview'; I'm not sure what this is called. I don't know anything about php but so far i've been able to get by just using google but I don't really know how to search for this. Thanks for all the help! Hello I need help with making our dropdown links stay visible when active. Site: London tshirt .com Code: [Select] <dl id="nav"> <dt class="nav"><b>London Tshirts</b></dt> <dd> <ul> <li><a href="/Unisex">Unisex</a></li> <li><a href="/Slimfit">Slimfit</a></li> <li><a href="/Kids">Kids</a></li> </ul> </dd> <dt class="nav"><b>Alternative Tshirts</b></dt> <dd> <ul class="nav"> <li><a href="/England">England</a></li> <li><a href="/Humour">Humour</a></li> <li><a href="/Popular">Popular</a></li> </ul> </dd> <dt class="nav"><b>Magnets</b></dt> <dd> <ul class="nav"> <li><a href="/magnets-ceramic">Ceramic</a></li> <li><a href="/magnets-metal">Metal</a></li> <li><a href="/magents-plastic">Plastic</a></li> </ul> </dd> <dt class="nav"><b>Keyrings</b></dt> <dd> <ul class="nav"> <li class="current"><a href="/keyrings-ceramic">Ceramic</a></li> <li class="current"><a href="/keyrings-metal">Metal</a></li> <li><a href="/keyrings-plastic">Plastic</a></li> </ul> </dd> <dt class="nav"><b>Other gifts</b></dt> <dd> <ul class="nav"> <li><a href="/Hats">Hats</a></li> <li><a href="/Models">Models</a></li> <li><a href="/Bags">Bags</a></li> </ul> </dd> </dl> Thanks P.S. I typed my question, then went to verification, but could not read the letters so requested a new image, this refreshed the page and I lost my message?? Hi, I am adding "active_filter", "passive_filter" classes to links based on regex pattern coming from the URL: Line 46: https://github.com/laanes/product_filtering/blob/master/APF_URL.php The function gets called on line 89 in he https://github.com/laanes/product_filtering/blob/master/boxes/advanced_product_filtering_box.inc.php You can see it in action he http://www.swanseatimber.co.uk/shop/hafele/brand_281.html by clicking on a category on the left, under the heading "Filter Your Results". The clicked category gets a green background because of the added "active_filter" class. When you click again, it will get "passive_filter" class and the products are not filtered any more. The problem: When moving to other pages by using the pagination at the top of the product results, the class doesn't get added. Therefore, you can't remove the filter because function creating the href on line 72 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php and the function clearing all filters on line 100 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php both fail. What's interesting - when selecting a filter, moving to the next page, clicking in the browser url bar and hiting enter(hard reload i think?), the problem disappears and you can play with the filters again. I really hope you find a minute to look into it and help me. I am displaying rows from a database onto a page using: while($row=mysql_fetch_array($query)){ echo $row['name']; } I need to figure out how to limit the rows shown to the page to 100. And if there are 100 rows on the page, a link will be displayed at the bottom, that says "Next 100". Then this will display the next 100 rows. Can you give an example how to do this please? Thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=317523.0 Hello, I have 2 questions... 1. Do you know of any good and easy php breadcrumb solution? 2. I have recently learned how to use PHP to make a navigation Active based on what page I am on (see below). If I am on the "currentPage" "contact.php" it will show it active... But, what I also want to do is have the main nav active on a sub-nav page. Is it possible to have 2 or more page referenced? Something like ($currentPage == 'contact.php' AND 'contact_form.php') Where both pages would make the link appear active and highlighted. <ul> <li><a href="contact.php" <?php if ($currentPage == 'contact.php') {echo 'id="here"';} ?>>Contact</a></li> <li><a href="about.php" <?php if ($currentPage == 'about.php') {echo 'id="here"';} ?>>About Us</a></li> <li><a href="careers.php" <?php if ($currentPage == 'careers.php') {echo 'id="here"';} ?>>Careers</a></li> <li><a href="services.php" <?php if ($currentPage == 'services.php') {echo 'id="here"';} ?>>Services</a></li> <li><a href="index.php" <?php if ($currentPage == 'index.php') {echo 'id="here"';} ?>>Home</a></li> </ul> Thank you in advance for your help i am making online jobs portal where people send data after finish work and then we check that update thier earning stat for that i am confused i want that if user earn 50$ per month we add those but when i next month add earning of that user that show show also 50$ and if i include 50 more there i can show last month earning one table and in one this month earn and in one table total earning till now and when USer earning total earning reach on 100$ or grater 100$ automatically show him 3 buttons where he can choose how he witdhraw the money and how much minimum $100 after once when he send us request for withdraw money those buttons again disapear and total balance - how much he requested us for withdraw so tell me how i make table strcute and which code i'll use I built a CMS system using CKEditor and KCFinder that store information od a databse via textarea/php. So far so good!
The issue comes to when I want to store and display images that link to themselves. The way I am storing images is exactly the same: There is a textarea where I insert an image via KCFinder/CKEditor. The image is uploaded to the server and the path stored at the database. Later I try to pick up that path from the database to display the image and because I want the image to link to itself, I try to use the same method to insert the url on the link. Problem? The link is missing and the images are not displaying.
Can anyone point me the error and suggest any solution? I would be so thankful! CODE: try { $DBH = new PDO('mysql:host=localhost;dbname=yourdb;charset=utf8', 'user', 'password'); $DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $STH = $DBH->prepare('SELECT * FROM php_maskiner ORDER BY timestamp DESC'); $STH->execute(); $STH->setFetchMode(PDO::FETCH_OBJ); while($row = $STH->fetch()) { $title = $row->title; $entry = $row->entry; $images = $row->images; $img_url = $row->images; $img_pack = '<div class="mask3 span3"> <a rel="prettyPhoto" href="'.$img_url.'"><img src="'.$images.'"></a> </div>'; } $DBH = null; } catch (PDOException $e) { echo '<div class="alert alert-standard fade in"> <a class="close" data-dismiss="alert" href="#">×</a> <strong>Can\'t read the database!</strong> </div><br />'.$e; } <?php echo '<article class="span12 post"> '.$img_pack.' <div class="inside"> <div class="span8 entry-content"> <div class="span12"> <h2>'.$title.'</h2> <p>'.$entry.'</p> </div> </div> </div> </article>'; ?> Thanks in advance! Hey everyone, I could use some help with this one.. I need to create some php code to switch images when a certain page loads. For example: These are the pages, test1, test2,test3, so when you click on the test1 link in the navigation a certain image would show up : something like this: If test1 exists then show image1.jpg If test2 exists then show image2.jpg If test3 exists then show image2.jpg. I am doing this in wordpress and I can't figure out the if then statement.. Does anyone have any ideas?? thanks ok, how do I make this button go to the specific link that is set with it.......it goes to page without eventid=eventid: Code: [Select] <form action= \"editevent.php?eventid=".$row['eventid']."\" method=\"link\"><INPUT TYPE=\"submit\" VALUE=\"Edit\"></form>"; I have created a database that echos out the result on a webpage, what i want to do is create one of the echo results into a link - the code is as follows: "Web Address: $web_address <br>" . Is there an easy way to make the result a link as the input will always be a web address? Thanks in advance! This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=307669.0 Hey, What i want is that if a username inserts some text into a field like "Hey @martin how are ya" ? then it will display @martin as a link that takes you to site.com/martin, i searched php.net from preg_replace and str_replace...unfortunately for me things got so complicated that i don't even want to talk about it. Anyone who can do it will be my saviour! I have a site, and there is an image with a link to another page, how can I make it so this is the only way to get to that page is by clicking on that image, and not by typing www.mywebsite.com/page.php into the address bar in a browser? Hi People. I am doing quite well with my www.airfieldcards.com website which is information for pilots in the UK and ireland should they wish to visit another airfield. It is in the form of a flight guide for free. Each card is held in a database and the cards are shown on the site by loading the following script /php/results.php?id=132 In the above example the card for c-moor in Ireland would be loaded. I want to be able to add a link within the cards that will give the user "the code" to enter that card within their own website. Sort of a "click here to get the code to add to your website" Then opening a separate box in a new window that had something like this in it. Copy and Paste the following code into your website Code: [Select] <iframe width="720" height="1500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://airfieldcards.com/php/results.php[b][i]"what goes here?"[/i][/b] What would I put into the bit "what goes here?" to dynamically load that specific card? and give the user the correct code to add into their own site? Thanks in advance, you guys on here have always been brilliant. I have a table where it displays some data. How do I make this Code: [Select] echo "<td>" . $row['title'] . "</td>"; into a link? Hi I would like to know how to make a link select certain stuff from the database. For example the link called cape town with the id 11 is selected then the link must search through the events table for the city_id 11 and take that information and display it in another page. I would like to know how to do that or can you let me know of place that I can look. I have tried google but I don't know how to put what I'm looking for in words Lets say that I want to make a certain word (or words) on a page a link. How would I make it a link without having to code in a link. Some site have adds on certain words; one day and not the next day. I am looking for similar feature, but less intrusive. No pop-up, just a link. I basically have a PHP Search Form, and when a user fills in a form it outputs the results. Each result displays a image of a property, how could i make them images have their own unique link which will take them directly to the page of the property being shown? Im using PHP and mySQL tables Any help is appreciated, Thank You. Heres the PHP that outputs the results: Code: [Select] <?php require_once 'mstr_ref.php'; function san($input){ if(get_magic_quotes_gpc()){ $input=stripcslashes($input); } $output = mysql_real_escape_string($input); return $output; } if(isset($_POST['submit'])){ $pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']); foreach ($pVars as $k=>$v){ $v = san($v); } $sql = new makeQuery(); $sql->manAdd('location_id', $pVars['area']); if($pVars['propType'] != 'Any'){ $sql->manAdd('catagory_id', $pVars['propType']); } if ($pVars['maxB'] > 0){ $sql->manAdd('bedrooms', $pVars['maxB'], '<='); } if($pVars['minB'] > 0){ $sql->manAdd('bedrooms',$pVars['minB'],'>='); } if($pVars['saleType'] != 'Any'){ if($pVars['saleType'] == "forsale"){ $sql->manAdd('market_type', 'sale'); if($pVars['minP'] != 0){ $pVars['minP'] = $pVars['minP'] * 1000; } if($pVars['maxP'] != 0){ $pVars['maxP'] = $pVars['maxP'] * 1000; } } if($pVars['saleType'] == 'forrent'){ $sql->manAdd('market_type', 'rent'); } } $qry = $sql->sqlStart.$sql->stmt.'Group By property.id'; $results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry"); if(mysql_num_rows($results) < 1){ die ("Sorry, No Results Match Your Search."); } while($row = mysql_fetch_assoc($results)){ echo '<div class="container" style="float:left;">'; echo '<div class="imageholder" style="float:left;">'; echo "<img class='image1' src='{$row['image_path']}' alt='{$row['summary']}'> <br />"; echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:14px; float:left; padding-top:10px;">'; echo "{$row['summary']}"; echo "<span style=\"color:#63be21;\"><br><br><b>{$row['bedrooms']} bedroom(s) {$row['bathrooms']} bathroom(s) {$row['receptions']} reception room(s)</b></span>"; if($row['parking'] != null){ echo "<span style=\"color:#63be21;\"><b> {$row['parking']} parking space(s)</b></span>"; } echo '</div>'; echo '<div style="clear:both"></div>'; } } else{ echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again"; } ?> |