Jump to content

jhodara

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jhodara's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi there, I know that php does not recognize onMouseOver events. however, Im wondering if their is a tricky way to get a javascript response from dynamic text. I am working on a nav menu in a wordpress site. wordpress has a function that displays a list of pages created in the admin. I want to be able to display a secondary list of pages when a top-level nav item is moused over. heres the code: <div id="top"> <script type="text/javascript"> function Show(who) { Clear(); divel=document.getElementById("drop"+who); divel.style.display="inline"; divel=document.getElementById("hn"+who); divel.className="selected"; } function Hide(who) { divel=document.getElementById("drop"+who); divel.style.display="none"; divel=document.getElementById("hn"+who); divel.className=""; } function Clear() { for (i=1;i<=3;i++) { divel=document.getElementById("drop"+i); divel.style.display="none"; divel=document.getElementById("hn"+i); divel.className=""; } } </script> <div id="home-nav" onMouseOut="Clear();"> <ul> <li id="hn1"><a href="wp_demo/profile" onMouseOver="Show('1')"><?php wp_list_pages(include=4&title_li=' ); ?></a></li> <li id="hn2"><a href="wp_demo/services" onMouseOver="Show('2')"><?php wp_list_pages( 'include=6&title_li=' ); ?></a></li> <li id="hn3"><a href="wp_demo/portfolio" onMouseOver="Show('3')"><?php wp_list_pages( 'include=8&title_li=' ); ?></a></li> <li id="hn4"><a href="wp_demo/contact" onMouseOver="Clear();"><?php wp_list_pages( 'include=12&title_li=' ); ?></a></li> <li id="hn5"><a href="wp_demo/hospitality" onMouseOver="Clear();"><?php wp_list_pages( 'include=10&title_li=' ); ?></a></li> </ul> </div> <!-- #homenav --> <div id="wrapper"> <div id="drop1" onMouseOver="Show('1')" onMouseOut="Hide('1')"> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/blank.gif" alt="" width="960" height="8" border="0" /><br /> <div id="menu1"><ul> <?php wp_list_pages( 'child_of=4&sort_column=menu_order&title_li=' ); ?> </ul></div></div> <div id="drop2" onMouseOver="Show('2')" onMouseOut="Hide('2')"> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/blank.gif" alt="" width="960" height="8" border="0" /><br /> <div id="menu2"><ul> <?php wp_list_pages( 'child_of=6&sort_column=menu_order&title_li=' ); ?> </ul></div></div> <div id="drop3" onMouseOver="Show('3')" onMouseOut="Hide('3')"> <img src="<?php bloginfo('stylesheet_directory'); ?>/images/blank.gif" alt="" width="960" height="8" border="0" /><br /> <div id="menu3"><ul> <?php wp_list_pages( 'child_of=8&sort_column=menu_order&title_li=' ); ?> </ul></div></div> Does anybody know a trick to get the dynamic text to be seen by the javascript? for example, if i put a inside the anchor tags before the php script starts, the onmouseover will register it, and display the secondary nav. I would place invisible divs with links on top of the dynamic text with z-index, but I want the text to be completely dynamic and the client to be able to add as many links as he/she wants. thanks!
  2. Hi, My issue here is that I cant get my query string variables to ONLY feed into if/else statement on my secondary page. I include my secondary page (fine.php) from my index page. My query string variables keep being fed back into my original if/ese statement on index.php. here is the if/else on index.php (these links work fine): <?php if($_SERVER['QUERY_STRING']=='/index.php' || $_SERVER['QUERY_STRING']=='') { include 'port.php'; } elseif (isset($_GET['pos'])){ include 'pos.php'; } elseif (isset($_GET['web'])){ include 'web.php'; } elseif (isset($_GET['fine'])){ include 'fine.php'; } else {include '404.php';} here is the if/else on my secondary page (fine.php). These links are supposed to alert the if/else in the next table cell. However, they instead alert the if/else in index.php. <td><br/> <a href="?backset"><img src="fine/thumbs/x-backset.jpg" border="0"></a><br/><br/> <a href="?backside"><img src="fine/thumbs/x-backside.jpg" border="0"></a><br/><br/> <a href="?bannerprint"><img src="fine/thumbs/x-bannerprint.jpg" border="0"></a><br/><br/> <a href="?chopu"><img src="fine/thumbs/x-chopu.jpg" border="0"></a><br/><br/> </td> <td><br/> <div id="DivPiece" align="left"> <?PHP if (isset($_GET['backset'])){ include 'fine/backset.php'; } elseif (isset($_GET['backside'])){ include 'fine/backside.php'; } elseif (isset($_GET['bannerprint'])){ include 'fine/bannerprint.php'; } elseif (isset($_GET['chopu'])){ include 'fine/chopu.php'; } ?> </div> </td> How can I get the links on the secondary page to only alert the if/else statement on that page, and BLOCK the if/else statement on index.php from seeing them? I still want to use the query string though. Thanks!
  3. So basically I need the php to skip over the first if/else statement and look straight in the next one. Anyone know how to do this? Is there an else {look in this file} type code that I can use at the end of my first if/else so It doesnt spit out the 404?
  4. Hi, My issue here is that I cant get my if/else statement to work on my secondary page. I include my secondary page (fine.php) from my index page. However, I have an if/else statement in fine.php that keeps reverting back to the index.php and, therefore, outputs the else statement (404.php) here is the if/else on index.php (these links work fine): <?php if($_SERVER['QUERY_STRING']=='/index.php' || $_SERVER['QUERY_STRING']=='') { include 'port.php'; } elseif (isset($_GET['pos'])){ include 'pos.php'; } elseif (isset($_GET['web'])){ include 'web.php'; } elseif (isset($_GET['fine'])){ include 'fine.php'; } else {include '404.php';} here is the if/else on my secondary page (fine.php). These links are supposed to alert the if/else in the next table cell. However, they instead alert the if/else in index.php. <td><br/> <a href="?backset"><img src="fine/thumbs/x-backset.jpg" border="0"></a><br/><br/> <a href="?backside"><img src="fine/thumbs/x-backside.jpg" border="0"></a><br/><br/> <a href="?bannerprint"><img src="fine/thumbs/x-bannerprint.jpg" border="0"></a><br/><br/> <a href="?chopu"><img src="fine/thumbs/x-chopu.jpg" border="0"></a><br/><br/> </td> <td><br/> <div id="DivPiece" align="left"> <?PHP if (isset($_GET['backset'])){ include 'fine/backset.php'; } elseif (isset($_GET['backside'])){ include 'fine/backside.php'; } elseif (isset($_GET['bannerprint'])){ include 'fine/bannerprint.php'; } elseif (isset($_GET['chopu'])){ include 'fine/chopu.php'; } ?> </div> </td> How can I get the links on the secondary page to only alert the if/else statement on that page, and BLOCK the if/else statement on index.php from seeing them? I still want to use the query string though. Thanks!
  5. Hi, I have these variables for pages I navigate to because I pass them in the query string. However, I need a variable for the homepage (index.php), before any query string is created. I cant declare a vari $_GET['intro'] ; $_GET['about'] ; $_GET['contact'] ; However, I need a variable for the homepage (index.php), before any query string is created. I cant declare a variable in index.php because it will be used throughout the entire website. I also cant declare the variable in home.php (the bulk content of the homepage) because I need to use the variable before home.php is included. Is their a trick for this? Thanks!
  6. Ya that worked thanks. Although I thought I could use a variable to simplify the code. whatever
  7. Hi folks, I was wondering how to do this. I want the if statement to detect if the query string has any of these values. so im trying to assign them all to the same variable. However, this code wont work. Whats the trick here? <?php $primary=$_GET['intro']; $primary=$_GET['port']; $primary=$_GET['about']; $primary=$_GET['contact']; if(isset($primary)){ echo "<img src='graphics/left-a.png'>";} else {echo "<img src='graphics/leftb.png'>";}?>
  8. Hi There, Im trying to figure out how to do this if/else statement. I need it to say, "if this is true, do this. if this is true, do this. If neither is true, do this. So there are three different possible outcomes. I tried to put each new if inside of the previous else. but that doesn't seem to work. $firstname = $_REQUEST['firstname']; $lastname = $_REQUEST['lastname']; if ($firstname == 'Joey' and $lastname == 'Hodara') { $output = 'Welcome to our site, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ', Oh Glorious Leader!'; } else { if ($firstname == 'Matt' and $lastname == 'Fig') { $output = 'Welcome to our site, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ', Portagee!'; } else{ if ($firstname == 'Jon' and $lastname == 'Spense') { $output = 'Welcome to our site, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ', bro!'; } } $output = 'Welcome to our site, ' . htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!'; ?>
  9. Hi there, im trying to have a form show up when user clicks "add joke". I need the variable to be retrieved from the url query string. I cant get the form to show up. I think its either an issue with the GET function at the top or the link down at the bottom. Please help! <?php // If the user wants to add a joke $_GET['addjoke'] = $addjoke; if (isset($addjoke)): ?> <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST> <P>Type your joke here:<BR> <TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP> </TEXTAREA><BR> <INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT"> </FORM> <?php else: // Connect to the database server $dbcnx = @mysql_connect("servername", "username", "password"); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); } // Select the jokes database if (! @mysql_select_db("jhodara2") ) { echo( "<P>Unable to locate the joke " . "database at this time.</P>" ); exit(); } // If a joke has been submitted, // add it to the database. $joketext = $_POST['joketext']; $submitjoke = $_POST['submitjoke']; if ("SUBMIT" == $submitjoke) { $sql = "INSERT INTO jokes SET " . "JokeText='$joketext', " . "JokeDate=CURDATE()"; if (mysql_query($sql)) { echo("<P>Your joke has been added.</P>"); } else { echo("<P>Error adding submitted joke: " . mysql_error() . "</P>"); } } echo("<P> Here are all the jokes " . "in our database: </P>"); // Request the text of all the jokes $result = mysql_query( "SELECT JokeText FROM jokes"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each joke in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["JokeText"] . "</P>"); } // When clicked, this link will load this page // with the joke submission form displayed. echo("<P><A HREF='$PHP_SELF?addjoke=1'>Add a Joke!</A></P>"); endif; ?> see the problem live at http://www.freewaycreative.com/insert2.php
  10. both "and" and "&&" work the same in PHP. Here was what I had to change <?php if ( $_POST[firstname] == "Joe" && $_POST[lastname] == "Shmo") { echo( "Welcome, Myself!" ); } else { echo( "Welcome, $_POST[firstname] $_POST[lastname]!" ); } ?> the PHP did not recognize $firstname and $lastname Thank you, though.
  11. Thanks Harristweed for the fix. But I took it one step further and put in an If/else conditional Heres the HTML <FORM ACTION="welcome.php" METHOD=POST> First Name: <INPUT TYPE=TEXT NAME="firstname"><BR> Last Name: <INPUT TYPE=TEXT NAME="lastname"> <INPUT TYPE=SUBMIT VALUE="GO"> </FORM> Heres the PHP: <?php if ( "Joe" == $firstname and "Shmo" == $lastname ) { echo( "Welcome, Myself!" ); } else { echo( "Welcome, $_POST[firstname] $_POST[lastname]!" ); } ?> When I enter Joe Shmo into the form, I want it to respond with, "Welcome, Myself". But it seems to skip the IF and go right to the ELSE. Anyone know what I am missing? I put this problem up live at http://www.freewaycreative.com/test
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.