every day, unloading a file that contains a set of url I have to change every day in css menu that I have the page. The only thing that does not change the name assigned to the url. You assigning each a name or other ID, go to the new url css menu without changing it every day?
Today
file.php
<a href='http://playlist.m3u.com/playlist1.m3u'>playlist1</a><br/>
<a href='http://playlist.m3u.com/playlist2.m3u'>playlist2</a><br/>
<a href='http://playlist.m3u.com/playlist3.m3u'>playlist3</a><br/>
Tomorrow
file.php
<a href='http://playlist.m3u.com/playlist4.m3u'>playlist1</a><br/>
<a href='http://playlist.m3u.com/playlist5.m3u'>playlist2</a><br/>
<a href='http://playlist.m3u.com/playlist6.m3u'>playlist3</a><br/>
Every day changes the url but not the playlist name
menu_index.html
<ul>
<li><a href='http://playlist.m3u.com/playlist1.m3u'>playlist1</a><br/></li>
<li><a href='http://playlist.m3u.com/playlist2.m3u'>playlist2</a></li>
<li><a href='http://playlist.m3u.com/playlist3.m3u'>playlist3</a></a></li>
</ul>
On this file, I change the link every day, but I would find a way to not edit it every day if possible.
The index is a menu in css menu dropdown, I would like to avoid having the classic white page with hyperlinks.
if i'm right understand you:
<?php $array = array('playlist1','playlist2','playlist3');?>
<ul><?php
foreach($array as $val){
?><li><a href='http://playlist.m3u.com/<?=$val?>.m3u'>playlist1</a><br/></li><?php
}
?></ul>
Related
How to add Flag icons next to logged in username in navbar?
Using Php oop MySQL database on a signup/login system. I have users_country as one of my database columns. This is put in the table as the classic two letter format, example: Netherlands is stored as NL.
After a user logs in I have my nav bar change from sign up, sign in
to usercountry & username, logout
I do that with php
Session start ()
echo $_SESSION[“usercountry”]
echo $_SESSION[“useruid”] (their username)
Now my navbar reads, example:
NLtestuser, logout
How do I go about replacing just the NL country code next to the username in the navbar to be an icon with the corresponding flag.
I would like the user to log in and the flag they selected upon signup will show instead of the flags two digit id.
I already have a flagicons folder in img folder in the root folder that contains all the flag icons with their corresponding countryid.png, example: nl.png
What is the simplest way to just change the country code to the icon flag when the user is logged in?
Thanks.
This is your code reformatted, with the code to show the flag:
<ul class="left-side">
<?php
if(isset($_SESSION["userid"])) {
?>
<li><img src="/img/<?php echo strtolower($_SESSION["usercountry"]); ?>.png" alt="flag"></li>
<li>logout</li>
<?php
} else {
?>
<li><a href='Signin.php'>Sign in</a></li>
<li><a href='signup.php'>Sign up</a></li>
<?php
}
?>
</ul>
Have a look at what the HTML source looks like if the image doesn't show up.
I'm building a website while also trying to keep changing code an easy task.
For that, I include the navbar with <?php require_once('./includes/navbar.php'); ?> so that I only need to change the navbar.php to see changes site-wide.
I also use Bootstrap 5 and let it take care of styling the currently active page by using <a class="active"> (and also using the recommended aria-current="page" attribute).
Now my problem is that I need to somehow dynamically apply the above mentioned class and tag to only the active page. I have no idea how to do that in an elegant way but thought that this might be possible in PHP?
Does somebody know how to do it?
Click here to see code of the navbar
I did some research and managed to fix my problem with a little bit of javascript code which you can just add with <script></script> tags anywhere in the html code:
Give every link in the navbar html a unique id (e.g. id="pricing").
Add class="active" to active page and Bootstrap.css will style that element accordingly.
Remove class="active" from the other pages/links which are not active.
Set aria-current="page" to active page and set aria-current="none" to inactive pages.
in navbar.php:
<a id="home" class="nav-link active" href="index.php">Home</a> <!-- 1. -->
<a id="pricing" class="nav-link" href="pricing.php">Pricing</a> <!-- 1. -->
in pricing.php:
<script>
var pricing = document.getElementById("pricing");
pricing.classList.add('active'); //2.
pricing.setAttribute("aria-current", "page"); //4.
var home = document.getElementById("home");
home.classList.remove('active'); //3.
home.setAttribute("aria-current","none"); //4.
</script>
Hope this may help someone else too.
I have this link in my db.php. I want everytime the dropdown menu is clicked it redirect to the corresponding page.
$ROOT_URL = '192.167.1.67/office/';
I want to go to this root url on the navigation every time i click on the link.
Home
<ul class="dropdown-menu">
<li>Add Product</li>
<li>View Product</li>
<li>Removed Product</li>
</ul>
instead the page is redirecting as
192.168.1.67/admin/192.168.1.67/admin/product/addproduct.php
How can i solve this problem??
use protocol before your url like..
$ROOT_URL = 'http://192.167.1.67/office/';
OR if having https $ROOT_URL = 'https://192.167.1.67/office/';
If the link points to a local location, you can just use / as root.
This, for examples will work:
Home
If $ROOT_URL is dynamic and you want to include the variable, define it as:
$ROOT_URL = '/office/';
Then you can do:
Home
Also, the links in the list
<ul class="dropdown-menu">
<li>Add Product</li>
<li>View Product</li>
<li>Removed Product</li>
</ul>
point to a relative URL, so when your current URL is /office, the links will point to: /office/addproduct.php. But if this navigation is also included on a page where the URL is /some/other/url, this link will point to: /some/other/url/addproduct.php.
Unless you are really sure the HTML with the link will only show at a certain path, try to avoid relative URLs.
I am experiencing a very strange problem.
I have 3 pages :
home.php
forums.php
projects.php
Every page has a menu like this:
<ul>
<li><a href='http://www.mysite.com'>Homepage</a></li>
<li><a href='forums.php'></a>Forums</li>
<li><a href='projects.php'></a>Projects</li>
</ul>
When the user is logged in sessions are set up and in every page on top username is shown.
If I'm in Projects page and my username is on top as I am logged in and now I want to go to main page, when I cycle through projects and forums the username is on top and sessions are not lost. When I click Homepage it goes to main page sessions are lost and the username is lost on the top.
I think the problem is with the first link Homepage.
When I do it index.php everything works fine but with this http:// it is not working. Actually sessions are still there but not showing up.
UPDATE
I think I found the problem
I converted all menu links to full links with http not only php files like this
<ul>
<li><a href='http://www.mysite.com'>Homepage</a></li>
<li><a href='http://www.mysite.com/forums.php'></a>Forums</li>
<li><a href='http://www.mysite.com/projects.php'></a>Projects</li>
</ul>
And everything works fine.
I am curious and I want to expand my knowledge. If anyone knows why is this happening please let me know.
converted all menu links to full links
No
http://www.mysite.com is not a valid URL, some webservers will assume that the path is '/', some browser will assume the path is '/' but most browsers will send the URL as is, and the webserver will usually send a redirect back to the browser.
As long as the host is the same in all cases or omitted, then the code will behave as you expect - but you really should use proper URLs to avoid subtle semantic issues i.e.
<ul>
<li><a href='http://www.mysite.com/'>Homepage</a></li>
<li><a href='http://www.mysite.com/forums.php'></a>Forums</li>
<li><a href='http://www.mysite.com/projects.php'></a>Projects</li>
</ul>
or...
<ul>
<li><a href='/'>Homepage</a></li>
<li><a href='/forums.php'></a>Forums</li>
<li><a href='/projects.php'></a>Projects</li>
</ul>
I have a dynamic page , which fetch data from database . Say for eg there are 2 record which is generated depending on query . So what i want to do is when some one click the Home link on 1st record , it should go to next page and over there php code is there which will increment the counter that is how many times the page is visted
Similarly when 2nd record Home link is clicked it should go to some page and then again again counter for that page is incremented
so say eg
Home Page - 1st Record - Page : http://www.abc.com/Wakad-T4248349
Home Page - 2nd Record - Page : http://www.abc.com/Himn-T3333333
Or another way of doing this , please help
<div id="menubar">
<ul>
<li class="current_page_item">
Home
<?php $_SESSION['Home']=$row['ID']; echo $_SESSION['Home'];?>
</li>
</ul>
</div>
<div id="menubar">
<ul>
<li class="current_page_item">
Home
<?php $_SESSION['Home']=$row['ID']; echo $_SESSION['Home'];?>
</li>
</ul>
</div>
Why not just have a field in the database which keeps track of how many times that particular page has been fetched? Or are you looking for unique IPs?
Assuming you don't control abc.com, you'll have to make the link go to one of your own pages:
<a href="redirect.php?link=abc.com/Wakad-T4248349"> ...
and on redirect.php, increase your counter (which you'll probably want to store in a DB...) and redirect them to the page.