I am currently working on a school project and appreciate your help.
HTML Code:
LINK 1
LINK 2
LINK 3
Now as I am relatively new to PHP, I need clue wehere to start or which topics are relevant for my solution. I have already searched the Forum here and with google, but unforutenly, didn't find anything, that fits my needs.
What I need, is a PHP-Code, that contains 6 href Links and every Link has a priority. So every time somebody clicks on "LINK 1" on the html file, he gets directed to the PHP-File "change-1.php", where one of the six href Links get activated.
PHP CODE "change-1.php":
<?php
if (condition) {
echo "http://www.someotherwebsite-1.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-2.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-3.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-4.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-5.com";
}
elseif (condition) {
echo "http://www.someotherwebsite-6.com";
}
?>
Perhaps this should help
LINK 1
LINK 2
LINK 3
Just create one change.php file
//to get change
<?php
if ($_GET['change'] == 1) {
echo "http://www.someotherwebsite-1.com";
}
elseif ($_GET['change'] == 2) {
echo "http://www.someotherwebsite-2.com";
}
elseif ($_GET['change'] == 3) {
echo "http://www.someotherwebsite-3.com";
}
elseif ($_GET['change'] == 4) {
echo "http://www.someotherwebsite-4.com";
}
elseif ($_GET['change'] == 5) {
echo "http://www.someotherwebsite-5.com";
}
elseif ($_GET['change'] == 6) {
echo "http://www.someotherwebsite-6.com";
}
?>
Now this is the basic idea. You can manipulate the data however you want.
I hope you got the concept.
I am a beginner when it comes to php.... I have the following:
I am not sure if it is my if statement expressed wrong or just at the wrong place. I want it not to show the records when the companyname == the businessname! Please advise?
if (mysql_num_rows($sql) > 0 && **($row['companyname'] == $user_data['businessname'])** )
{
while ($row = mysql_fetch_array($sql)){
if (($employed =='1')){
echo '<h4> ID : '.$row['idnumber'] ;
echo '<br> First Name : '.$row['firstname'];
echo '<br> Last Name : '.$row['lastname'];
echo '<br> Reference 1 : '.$row['ref1'];
echo '<br> Reference 2 : '.$row['ref2'];
echo '<br> Reference 3 : '.$row['ref3'];
echo '<br> Gender : '.$row['gender'];
echo '<br> Company : '.$row['companyname'];
echo ' </h4>';
echo '<br />';
echo '<h2>Some Additional Options</h2>';
echo '<br />';
include 'includes/admenu.php';
}
}
}
else
{
print ("$XX");
}
The $row variable doesn't exist outside your loop, so it's pointless trying to use it in the if statement. You need to move it inside the loop, like so:
while ($row = mysql_fetch_array($sql))
{
if ( ($employed =='1') && ($row['companyname'] == $user_data['businessname']) )
{
// code ...
}
}
I want it not to show the records when the companyname == the businessname!Move the statement inside your loop:
I'm not actually sure if you're trying to display when companyname == the businessname or companyname != the businessname. Either way, change your if condition accordingly and it should work.
My piece of code.
And problem now are about styling, i just want style page number, wich is open, like a active id, if page open, then that number is in different color or smth else.
I need make a new variable? Or what, i just try to add but its wont work, it only works if at the end i write echo $page; , then it show style on this, but i need on links, numbers.
<?php
if($total_pages > 1){
if($page != 1){
echo ' < ';
}
for($number=1;$number<=$total_pages;$number++)
{
echo ''.$number.'';
}
if($page != $total_pages){
echo ' > ';
}
}
?>
You can do something like this.
$currentPageNumber = $_GET['page'];
for($number=1;$number<=$total_pages;$number++){
$currentPageStyle = '';
if($number == $currentPageNumber){
$currentPageStyle = 'style="color:red"';
}
echo '<a href="?page='.$number.'" '.$currentPageStyle.'>'.$number.'</a>';
}
My name is Manuel, I am a web design student and am starting to take my first steps with web design. Recently I tried to validate
this site:
http://accesosnormalizados.com
I used the W3C validator, at first I found about 30 errors, and can correct them all except one that says: 'there is no attribute
"onload"'.
Apparently not support XHTML onload tag, and I use a Joomla extension called Vertical Menu using onload. This is a free extension and works well but I have found it has some bugs, especially when validating the website.
This is the PHP code for extension:
get( 'menutype', 'mainmenu' );
$qry = "SELECT id, name,parent, link,type,browserNav FROM #__menu WHERE menutype = '".$menutype."' AND published = 1 ORDER BY ordering";
$database->setQuery($qry);
$rows = $database->loadObjectList();
if(isset($GLOBALS['vertical_menu'])) $GLOBALS['vertical_menu']++;
else $GLOBALS['vertical_menu'] = 0;
function getMenuChildList($rows, $parentId) {
$childRows = array();
foreach ($rows as $row) {
if ($row->parent == $parentId) {
$childRows[] = $row;
}
}
return $childRows;
}
function drawVerticalMenu($rows, $showsubcats, $parentId = 0) {
$categories = $showsubcats || !$parentId ? getMenuChildList($rows, $parentId) : array();
if ($parentId) {
if (!count($categories)) {
echo '';
return;
} else echo '';
echo '';
} else echo '';
echo '';
foreach ($categories as $category) {
$link = $category->link. (preg_match("/^http:\/\/|^https:\/\//",$category->link)? "" : '&Itemid='.$category->id);
$blank = $category->browserNav? ' target="_blank" ' : ' ';
echo 'id.'" class="menu">'.$category->name.' ';
drawVerticalMenu($rows, $showsubcats, $category->id);
}
echo '';
if ($parentId && count($categories)) echo '';
}
$document = &JFactory::getDocument();
$document->addScript('https://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dojo/dojo.xd.js');
$document->addScript('modules/mod_vertical_menu/script/menu.js');
$document->addStyleSheet('modules/mod_vertical_menu/style/menu.css');
$document->addCustomTag('
div#MenuContainer'.$GLOBALS['vertical_menu'].' table#VerticalMenu'.$GLOBALS['vertical_menu'].' {
width: '.$params->get('categorymenu_width', 150).'px;
opacity: '.$params->get('categorymenu_out', 0.8).';
FILTER: progid:DXImageTransform.Microsoft.Alpha(Opacity='.($params->get('categorymenu_out', 0.8)*100).');
}
');
echo '';
drawVerticalMenu($rows, $params->get('show_subcats', 1));
echo 'get('categorymenu_out', 0.8).',over : '.$params->get('categorymenu_over', 1).',duration : '.$params->get('categorymenu_fade', 300).',id : '.$GLOBALS['vertical_menu'].',width : '.$params->get('categorymenu_width', 150).'});" alt=""/>';
echo '';
?>
The problem is at the end:
echo '';
drawVerticalMenu($rows, $params->get('show_subcats', 1));
echo 'get('categorymenu_out', 0.8).',over : '.$params->get('categorymenu_over', 1).',duration : '.$params->get('categorymenu_fade', 300).',id : '.$GLOBALS['vertical_menu'].',width : '.$params->get('categorymenu_width', 150).'});" alt=""/>';
echo '';
?>
I think the extension uses the onload event to display the sub-menus when the user moves the mouse pointer over it.
What I want is to replace the onload with other event handler or some other label that is supported by XHTML and that is as similar to onload.
I would appreciate your help ...
You can remove the onload attributes and then add some simple javaScript to your page to run some functions when the page finishes loading.
It would look something like this:
<script>
window.onload=function(){
new WW.VerticalMenu({out : 1,over : 1,duration : 300,id : 0,width : 180}); // example of one of the functions being run
};
</script>
Good luck with your studies
It appears the source comes out like this right
<img src="/modules/mod_vertical_menu/images/center.gif" style="display:none" onload="new WW.VerticalMenu({out : 1,over : 1,duration : 300,id : 0,width : 180});" alt=""/>
As that looks like imho an unsavoury method of instantiating the menu I would try and loose that attribute completely by removing the offending php echo section and instead add javascript to load
as this is using dojo maybe this will help -- sorry I do not use dojo
http://mail.dojotoolkit.org/pipermail/dojo-interest/2012-May/066106.html
so php wise this would be
echo '<img src="modules/mod_vertical_menu/images/center.gif" style="display:none" alt=""/>'; echo '</div>';
echo "<script>" ."javascript or dojo script here ".</script>"
I would even suggest removing the image and using the window onload advocated below if you can
I have a situation whereby i want two of my pages to look different form the rest but they are not front pages. If they were it would be easy as the code below would do the trick.
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
esle(do something else)
}
?>
In short i want a similar approach but this time, to get the menu by ID/URL. Any ideas?
I got the answer to this...all you need to check is the menu ID then put the code below.
<?php
//This is the code for the page with menu ID 6
$menuID = JSite::getMenu()->getActive()->id ;
if ($menuID == '6')
{
echo '';
}
elseif ($menuID == '2') //This is the HTML for page with menu ID 2
{
echo '';
}
elseif ($menuID == '4') //THis is the html for page with menu id 4
{
echo '';
}
else //This is the HTML code for the rest of the pages
{
echo '';
}
?>
Page ItemId can be obtained using $itemid = JRequest::getInt( 'Itemid' );