Jump to content

kyleldi

Members
  • Posts

    148
  • Joined

  • Last visited

    Never

Posts posted by kyleldi

  1. Thank you for the valuable information!  I put together the code (below), but it seems as though the alternating does not take place.  Instead it just outputs each TR class at

    <tr class="staff_e">

     

     

    <?php do { ?>
            <?php $alt = 0; ?>
            <tr class="<?php echo ($alt) ? 'staff_o' : 'staff_e'; ?>">
              <td><?php echo ucwords($row_rs_staff['name']); ?></td>
              <td><?php echo $row_rs_staff['dept']; ?></td>
              <td><?php echo $row_rs_staff['ext']; ?></td>
            </tr>
            <?php $alt = ($alt) ? 0 : 1; ?>
            <?php } while ($row_rs_staff = mysql_fetch_assoc($rs_staff)); ?>

  2. I'm creating a staff directory that I'd like to use alternating background colors (odd/even) to make it easier to read.  All of the information is stored in sql, which I can pull to the page with a repeat function, but I'm not sure how to get the zebra effect to alternate with the output.  Is there any easy way to do this?  I'm using CSS to change the background of the table itself.

     

    <table width="100%" border="0" cellpadding="1" cellspacing="0" class="staff_b">
            <tr>
              <td width="35%"><div class="staff_h">Name</div></td>
              <td width="35%"><div class="staff_h">Department</div></td>
              <td width="30%"><div class="staff_h">Extension</div></td>
            </tr>
            <tr class="staff_e">
              <td>1</td>
              <td>2</td>
              <td>3</td>
            </tr>
            <tr class="staff_o">
              <td>4</td>
              <td>5</td>
              <td>6</td>
            </tr>
          </table>
    

  3. Using Cag's script:

     

    <?php
    if($_SERVER['HTTP_REFERER'] != "http://www.google.com") {
       header("Location: http://www.yahoo.com");
       exit();
    }
    ?>
    <!-- all the HTML in the world can go here -->

     

    How would I add a second URL that's allowed as a referrer?  I tried the array option posted here but I couldn't make it work, and after reading on php array, I don't see how i'm going to get it to work.

  4. I'd like to make an IF statement making a page redirect if it's not being accessed via a certain page.  Essentially something like this:

     

    IF $referer does not equal mypage.php

     

    redirect to retry.php

     

    else

     

    PHP Form

     

    The problem is, I don't want to send the header too early or it won't work, so I'm having a hard time writing the script.  Does anyone have any direction?  Thank you!

  5. I'd like to limit the session length on one specific page on this site i'm working with.  I've done the following code, but it doesn't matter if I set it to 5 or 1500, the page will not time-out on refresh.  Any ideas how I can make this work?  I'd like the session to only last like two minutes, so if the person calls the same page up again it will tell them to go back to the main page and start over.

     

    <?php
    ini_set('session.gc_maxlifetime', 5); 
    session_start();
    ?>

  6. I've got a form that asks someone to enter a code before continuing to the next page.  This information is posted by the form using $_POST.  On the next page, I'd like a hidden field with that code in it, so I can post it to a different database and work with it there.  Is there a way to obtain what was posted w/o passing it through the URL?  The Session is open on both pages, so I'd be left to believe it's available, I just don't understand how to call for it w/o using a URL variable.

  7. I've got a script to allow me to echo the URL of the current page on the page itself, but it won't seem to work with dynamic urls (such as services.php?service=name).  I'm not completely sure what I need to change.  Any ideas?  Thanks!

     

    <?php
    function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }
    ?>

  8. I've got this menu that has some drop down sections.. It works fine and all is well, but where it drops down it goes behind the video playing underneath it.  I've tried setting the Z-Index to 999, and the position is absolute, but it still goes behind the video.  Any ideas?  I've also set the vmode to transparent in the flash code as well.  Here's my stylesheet if it helps... Thank you!

     

    .jqueryslidemenu{
    font: bold 12px Verdana;
    width: 100%;
    background-color: #363636;
    background-repeat: repeat-x;
    }
    
    .jqueryslidemenu ul{
    margin: 0;
    padding: 0;
    list-style-type: none;
    }
    
    /*Top level list items*/
    .jqueryslidemenu ul li{
    position: relative;
    display: inline;
    float: left;
    }
    
    /*Top level menu link items style*/
    .jqueryslidemenu ul li a{
    display: block; /*background of tabs (default state)*/
    color: white;
    padding: 8px 10px;
    color: #2d2b2b;
    text-decoration: none;
    background-color: #363636;
    }
    
    * html .jqueryslidemenu ul li a{ /*IE6 hack to get sub menu links to behave correctly*/
    display: inline-block;
    }
    
    .jqueryslidemenu ul li a:link, .jqueryslidemenu ul li a:visited{
    color: #999999;
    }
    
    .jqueryslidemenu ul li a:hover{
    color: #FFFFFF;
    background-color: #363636;
    background: url(../images/nav_hover.jpg);
    background-repeat: repeat-x;
    background-position: bottom;
    }
    
    /*1st sub level menu*/
    .jqueryslidemenu ul li ul{
    position: absolute;
    left: 0;
    display: block;
    visibility: hidden;
    }
    
    /*Sub level menu list items (undo style from Top level List Items)*/
    .jqueryslidemenu ul li ul li{
    display: list-item;
    float: none;
    }
    
    /*All subsequent sub menu levels vertical offset after 1st level sub menu */
    .jqueryslidemenu ul li ul li ul{
    top: 0;
    }
    
    /* Sub level menu links style */
    .jqueryslidemenu ul li ul li a{
    font: normal 13px Verdana;
    width: 160px; /*width of sub menus*/
    padding: 5px;
    margin: 0;
    }
    
    .jqueryslidemenuz ul li ul li a:hover{ /*sub menus hover style*/
    color: #333333;
    background-color: #eff9ff;
    background: url(../images/nav_hover.jpg);
    background-repeat: repeat-x;
    background-position: bottom;
    }
    
    /* ######### CSS classes applied to down and right arrow images  ######### */
    
    .downarrowclass{
    position: absolute;
    top: 12px;
    right: 7px;
    }
    
    .rightarrowclass{
    position: absolute;
    top: 6px;
    right: 5px;
    }
    

  9. I've got a page on this site I'm working on that has a drop down menu that varies based on what is in the Format column.  How would I set up my IF statement?  So far I'm running into snags.  This is what I've come up with so far, but I think I'm a little off track. Can anyone help throw me in the right direction?  There is only a possibility of four different options in that column, so I don't really need an else statement for if it doesn't meet either of the previous four criteria.

     

    <?php 
    if ($row_rs_itemdetail['format']==Format1)
    {
    echo 'Format 1 Dropdown';
    if ($row_rs_itemdetail['format']==Format2)
    {
    echo 'Format 2 Dropdown';
    if ($row_rs_itemdetail['format']==Format3)
    {
    echo 'Format 3 Dropdown';
    if ($row_rs_itemdetail['format']==Format4)
    {
    echo 'Format 4 Dropdown';
    }?>

     

    Thank You, :)

  10. hrm... it errors on the echo line beneath it now.  Here's my code.

     

    <?php
    if (isset ($_GET['category']) && isset ($_GET['sub'])) { // Output if both Category & Subcategory is submitted //
      echo '<h1><span class="red_upcap">' . ucwords($row_rs_subcategories['category']) . ' > ' . ucwords($row_rs_subcategories['sub']) . '</h1>';
      do {
        echo '<div class="categories"><a href="itemdetail.php?itemid=' . $row_rs_subcategories['itemid'] . '"><img src="store/thumbs/' . $row_rs_subcategories['img_t'] . '" alt="' . ucwords($row_rs_subcategories['category']) . '" width="' . $row_rs_subcategories['img_t_x'] . '" height="' . $row_rs_subcategories['img_t_y'] . '" border="0" longdesc="itemdetail.php?itemid=' . $row_rs_subcategories['itemid'] . '" /></a></div>';
      } while ($row_rs_subcategories = mysql_fetch_assoc($rs_subcategories));
    } elseif (isset ($_GET['category'])) { // Output if just Category is submitted. //
      if ($row_rs_nosub['sub'] == '') { // No subcategory exists //
        echo '<h1><span class="red_upcap">C</span>ategory: ' . ucwords($row_rs_nosub['category']) . '</h1>';
        do {
          echo '<div class="categories"><a href="itemidetail.php?itemid=' . $row_rs_nosub['itemid'] . '"><img src="store/thumbs/' . $row_rs_nosub['img_t'] . '" alt="' . ucwords($row_rs_nosub['category']) . '" width="' . $row_rs_nosub['img_t_x'] . '" height="' . $row_rs_nosub['img_t_y'] . '" border="0" longdesc="itemidetail.php?itemid=' . $row_rs_nosub['itemid'] . '" /></a><br />
                                    <a href="itemidetail.php?itemid=' . $row_rs_nosub['itemid'] . '">' . ucwords($row_rs_nosub['item_name']) . '</a></div>';
        } while ($row_rs_nosub = mysql_fetch_assoc($rs_nosub));
      } else {
        if(isset($row_rs_cats['sub']) // If subcategory is not empty //
          echo '<h1><span class="red_upcap">C</span>ategory: ' . ucwords($row_rs_cats['category']) . '</h1>';  // error here //
        do {
          echo '<div class="categories"><a href="itemdetail.php?itemid=' . $row_rs_subcategories['itemid'] . '"><img src="store/thumbs/' . $row_rs_subcategories['img_t'] . '" alt="' . ucwords($row_rs_subcategories['category']) . '" width="' . $row_rs_subcategories['img_t_x'] . '" height="' . $row_rs_subcategories['img_t_y'] . '" border="0" longdesc="itemdetail.php?itemid=' . $row_rs_subcategories['itemid'] . '" /></a></div>';
        } while ($row_rs_subcategories = mysql_fetch_assoc($rs_subcategories));
      }
    } else { // Output if no URL Variable is submitted //  // This line errors //
      echo '<h1><span class="red_upcap">C</span>ategory: ' . ucwords($row_rs_categories['category']) . '</h1>';
      do {
        echo '<div class="categories"><a href="store.php?category=' . str_replace(" ", "+", $row_rs_categories['category']) . '"><img src="store/thumbs/' . $row_rs_categories['img_t'] . '" alt="' . ucwords($row_rs_categories['category']) . '" width="' . $row_rs_categories['img_t_x'] . '" height="' . $row_rs_categories['img_t_y'] . '" border="0" longdesc="store.php?category=' . str_replace(" ", "+", $row_rs_categories['category']) . '" /></a><br />
                            <a href="store.php?category=' . str_replace(" ", "+", $row_rs_categories['category']) . '">' . ucwords($row_rs_categories['category']) . '</a></div>';
      } while ($row_rs_categories = mysql_fetch_assoc($rs_categories));
    }
    ?>

     

    Maybe i'm writing it wrong?

  11. I hope i'm not being confusing.  One if statement says if the field is blank, do something, the other says if it's got anything in it, do something else.  The problem I believe is I dont know how to say if it's "anything" else.  The recordset it refers to filters it by whatever that subcategory is entered there.

  12. All seems to be working now... But my query that says IF "sub" = '' doesn't do what i'm looking to make it.  Is there a way to say if anything exists in that column then to echo?  Right now it doesn't echo anything if something that doesn't equal N/A.  I'm guessing its cause it doesn't read "" as anything.

  13. So here's my problem, I've got an IF statement that basically changes the output of a page based on URL variables.  It's for a simple gallery.  Basically if no URL variable is submitted all categories are outputted with a thumbnail to that category.  This works just fine.  If you click on a subcategory it re queries the page and grabs the category url variable, which is where my script breaks.  What I want it to do is query the db to make sure there is something in the 'sub' field, otherwise it makes the hyperlink of the photos different (essentially eliminating the subcategory query).  What's happening now is the page gives me a parse error of "unexpected t_else" at the last ELSE statement in the code.  I know it's got something to do with how I have my code laid out, but I can't figure out how to lay it out correctly.  Any pointers would be appreciated!!

     

    <?php
        if(isset($_GET['category']) && isset($_GET['sub'])){   // Output if both Category & Subcategory is submitted //
    echo '<h1><span class="red_upcap">'.ucwords($row_rs_subcategories['category']).' > '.ucwords($row_rs_subcategories['sub']).'</h1>';
       do { 
          echo '<div class="categories"><a href="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'"><img src="store/thumbs/'.$row_rs_subcategories['img_t'].'" alt="'.ucwords($row_rs_subcategories['category']).'" width="'.$row_rs_subcategories['img_t_x'].'" height="'.$row_rs_subcategories['img_t_y'].'" border="0" longdesc="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'" /></a></div>';
    }
        while ($row_rs_subcategories = mysql_fetch_assoc($rs_subcategories));
    }
    else
    if(isset($_GET['category'])){  // Output if just Category is submitted. //
    if ($row_rs_cats['sub']=='N/A')  // No subcategory exists //
    echo '<h1><span class="red_upcap">C</span>ategory: '.ucwords($row_rs_cats['category']).'</h1>' ;
       do {
        echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",strtolower($row_rs_cats['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_cats['sub'])).'"><img src="store/thumbs/'.$row_rs_cats['img_t'].'" alt="'.ucwords($row_rs_cats['category']).'" width="'.$row_rs_cats['img_t_x'].'" height="'.$row_rs_cats['img_t_y'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",strtolower($row_rs_cats['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_cats['sub'])).'" /></a><br />
        <a href="store.php?category='.str_replace(" ","+",$row_rs_cats['category']).'&sub='.str_replace(" ","+",$row_rs_cats['sub']).'">'.ucwords($row_rs_cats['sub']).'</a></div>';
    }
        while ($row_rs_cats = mysql_fetch_assoc($rs_cats));
    }
    else{
    if ($row_rs_cats['sub']=='')  // If subcategory is not empty //
    echo '<h1><span class="red_upcap">C</span>ategory: '.ucwords($row_rs_cats['category']).'</h1>' ;
       do { 
          echo '<div class="categories"><a href="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'"><img src="store/thumbs/'.$row_rs_subcategories['img_t'].'" alt="'.ucwords($row_rs_subcategories['category']).'" width="'.$row_rs_subcategories['img_t_x'].'" height="'.$row_rs_subcategories['img_t_y'].'" border="0" longdesc="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'" /></a></div>';
    }
        while ($row_rs_subcategories = mysql_fetch_assoc($rs_subcategories));
    }
    else{  // Output if no URL Variable is submitted //  // This line errors //
    echo '<h1><span class="red_upcap">C</span>ategory: '.ucwords($row_rs_categories['category']).'</h1>' ;
    do {
       echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'"><img src="store/thumbs/'.$row_rs_categories['img_t'].'" alt="'.ucwords($row_rs_categories['category']).'" width="'.$row_rs_categories['img_t_x'].'" height="'.$row_rs_categories['img_t_y'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'" /></a><br />
        <a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'">'.ucwords($row_rs_categories['category']).'</a></div>';
    }
    while ($row_rs_categories = mysql_fetch_assoc($rs_categories)) ;
    }
    ?>

  14. <?php
      if(isset($_GET['category']) && isset($_GET['sub'])){ 
        echo '<h1><span class="red_upcap">'.ucwords($row_rs_subcategories['category']).' > '.ucwords($row_rs_subcategories['sub']).'</h1>';
        do { 
          echo '<div class="categories"><a href="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'"><img src="store/thumbs/'.$row_rs_subcategories['img_t'].'" alt="'.ucwords($row_rs_subcategories['category']).'" width="'.$row_rs_subcategories['img_t_x'].'" height="'.$row_rs_subcategories['img_t_y'].'" border="0" longdesc="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'" /></a></div>';
       } while ($row_rs_subcategories = mysql_fetch_assoc($rs_subcategories));  // User submits category & subcategory
    } else if (isset($_GET['category'])) {
        echo '<h1><span class="red_upcap">C</span>ategory: '.ucwords($row_rs_categories['category']).'</h1>' ;
        do { //1
          if ($row_rs_categories['sub']=='N/A') {
            echo '<div class="categories"><a href="itemdetail.php?itemid='.$row_rs_categories['itemid'].'"><img src="store/thumbs/'.$row_rs_categories['img_t'].'" alt="'.ucwords($row_rs_categories['category']).'" width="'.$row_rs_categories['img_t_x'].'" height="'.$row_rs_categories['img_t_y'].'" border="0" longdesc="itemdetail.php?itemid='.$row_rs_categories['itemid'].'" /></a><br />
                  <a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'&sub='.str_replace(" ","+",$row_rs_categories['sub']).'">'.ucwords($row_rs_categories['sub']).'</a></div>';
          } else { //2 //3
            echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",strtolower($row_rs_categories['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_categories['sub'])).'"><img src="store/thumbs/'.$row_rs_categories['img_t'].'" alt="'.ucwords($row_rs_categories['category']).'" width="'.$row_rs_categories['img_t_x'].'" height="'.$row_rs_categories['img_t_y'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",strtolower($row_rs_categories['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_categories['sub'])).'" /></a><br />
                  <a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'&sub='.str_replace(" ","+",$row_rs_categories['sub']).'">'.ucwords($row_rs_categories['sub']).'</a></div>';
        } while ($row_rs_categories = mysql_fetch_assoc($rs_categories));  //1
      }
    } else { //2ND ELSE
      echo '<h1><span class="red_upcap">C</span>ategory: '.ucwords($row_rs_cats['category']).'</h1>' ;
      do {
        echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",strtolower($row_rs_cats['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_cats['sub'])).'"><img src="store/thumbs/'.$row_rs_cats['img_t'].'" alt="'.ucwords($row_rs_cats['category']).'" width="'.$row_rs_cats['img_t_x'].'" height="'.$row_rs_cats['img_t_y'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",strtolower($row_rs_cats['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_cats['sub'])).'" /></a><br />
              <a href="store.php?category='.str_replace(" ","+",$row_rs_cats['category']).'&sub='.str_replace(" ","+",$row_rs_cats['sub']).'">'.ucwords($row_rs_cats['sub']).'</a></div>';
      } while ($row_rs_cats = mysql_fetch_assoc($rs_cats));
    }
    ?>

     

    This matches your syntax above, correct?  Yet I still get the same parse error.

     

    All i'm trying to do is let this page load the content based on the url variable.  If the variable exists it does the first check for category and sub, if it doesn't find that it looks for just category, where it checks to see if there is anything in the 'sub' column.  If there is, it outputs a picture w/ a hyperlink that includes the sub as a variable, if there's no sub in the column, it's supposed to output a picture w/ a hyperlink to the picture's details.

×
×
  • 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.