Jump to content

Colton.Wagner

Members
  • Posts

    157
  • Joined

  • Last visited

Posts posted by Colton.Wagner

  1. I don't know that this is exactly what you are asking but if it is not please be more specific:

     

    <?php   
    
            $id = $_GET['id']; 
                if($id == '1'){
                    header("location: ./index.php?id=1");
                }
            $result = mysql_query("SELECT * FROM pages WHERE id='$id' ",$connect);
            while($row = mysql_fetch_assoc($result)){
                echo $row['anything1']; 
                echo $row['anything2']; 
            } 
    ?>

  2. To achieve what you are asking you must dissect the entire lightbox script. Right now it looks for the Element Attribute src and takes that value to produce a picture. You must allow the script to find a Link that has some id in it that tells the script where the form is at. Making the form dynamic using ajax would be really cool and if you could get it to go back to the lightbox loading circle after you hit submit would be really cool. I think this would be possible with a little reverse engineering. Good luck and let me know if you find anything!

     

    Thanks,

    Colton Wagner

  3. So basically you have six categories of data with a total of 50 entries within that category. The way I am reading this you want to be able to view all 50 entries and go through these "data" fields or categories. Is that close to correct?

     

    Thanks,

    Colton Wagner

  4. I am assuming you have no knowledge of ajax. Ajax makes it so you can access data without reloading a page. Basically you are going to need to use the ORDER BY mysql statement and send a variable through ajax so that a secondary php page can read it. I would reccomend moving this post to the General Discussion -> AJAX Help you will find a lot more helpful answers there.

    Thanks,

    Colton Wagner

  5. if you change the range in the fist set of code:

    <?php
      session_start();
    
      // session timing
      // set timeout period in seconds
      $inactive = 120;
    
      // check to see if $_SESSION['timeout'] is set
        if(isset($_SESSION['timeout']) ) {
          $session_life = time() - $_SESSION['timeout'];
            if($session_life > $inactive)  {
              session_destroy(); }
        }
    
        $_SESSION['timeout'] = time();
    
      // END session timing
    
      include('library/login.php');
      login();
      mysql_select_db('test');
       
    
      // sets the sessions for all values
      $_SESSION=array_merge($_SESSION,$_POST);
      
        // echoing to verify
      $gender=$_SESSION[gender];
      $genderPref=$_SESSION[genderPref];
        echo "Chossen Gender".$_SESSION['gender'];
        echo "<br><Br>";
        echo "GenderPref".$_SESSION['genderPref'];
        echo "<br><Br>";
        
        
    
      // if the user has been timed out or not logged in
      if (!isset($_SESSION['clientID'])){
        echo "You are not a register user - set this to a simple search form";
        echo "<br><a href='form.php'>Form</a>";
      }
    
      // user is logged in
      else {
        $clientID = $_SESSION['clientID'];
    
        $sql="SELECT * FROM user WHERE userID='$clientID'";
        $result=mysql_query($sql);
    
        while ($r=mysql_fetch_array($result)) {
          $exp_date=$r["exp_date"];
          $todays_date=date("Y-m-d");
        }
    
      // verifies billing
      if ($exp_date >= $todays_date) {
    
        // billing is up to date
        $result = mysql_query("SELECT * FROM user WHERE gender='$gender'") or die(mysql_error());
    
    // ------ Sets the display of data ------
          $num_rows = mysql_num_rows($result);
    
          // number of rows to show per page
          $rowsperpage = 8;
    
          // find out total pages
          $totalpages = ceil($num_rows / $rowsperpage);
    
          // get the current page or set a default
          if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
            // cast var as int
            $currentpage = (int) $_GET['currentpage'];  }
          else {
            // default page num
            $currentpage = 1; } // end if
    
          // if current page is greater than total pages...
          if ($currentpage > $totalpages) {
            // set current page to last page
            $currentpage = $totalpages; } // end if
    
          // if current page is less than first page...
            if ($currentpage < 1) {
              // set current page to first page
              $currentpage = 1; } // end if
    
              // the offset of the list, based on current page
              $offset = ($currentpage - 1) * $rowsperpage;
    
    
    
      $result = mysql_query("SELECT * FROM user WHERE gender='$gender' LIMIT $offset, $rowsperpage")or  die(mysql_error());
        $num_rows = mysql_num_rows($result);
        if ($num_rows == 0){
          echo "<div id='noResults'><span class='sorry'>Sorry</span>, no results found. <br> Please try again with broader search options.</div>"; }
        else {
          // format for search results
          $cells_wide = 2;
          echo " <table cellspacing='0' cellpadding='3' border='0' width='700'><tr> ";
          $c = 0;
    
          while ($r=mysql_fetch_array($result)) {
            $userID=$r["userID"];
            $gender=$r["gender"];
            $aUserIDs[] = $userID;
    
              if (0 < $c && 0 == $c % $cells_wide){
                echo " </tr><tr> "; }
                echo " <td width=175> ";
                echo "<a href='profileSession.php?userID=$r[userID]'>$userID</a>, $gender</td>";
                $c++;
              } // end of while
              echo " </tr>";
              echo " </table> ";
        }
    // -------- BUILD THE PAGINATION LINKS --------------------------------
    
        $_SESSION['userID']=$aUserIDs;
        $_SESSION['userID2']=$aUserIDs2;
        echo "<div id='navigation'>";
    
        // range of num links to show
        [color=red]$range = 3;[/color]
    
        // if not on page 1, show back links
        if ($currentpage > 1) {
          // show << link to go back to page 1
          echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>‹‹ </a> ";
    
          // get previous page num
          $prevpage = $currentpage - 1;
    
          // show < link to go back to 1 page
          echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'> ‹ </a> ";
        } // END if ($currentpage > 1)
    
        // loop to show links to range of pages around current page
        for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
          // if it's a valid page number...
          if (($x > 0) && ($x <= $totalpages)) {
            // if we're on current page...
            if ($totalpages == 1) {
              echo "";  }
            else{
              if ($x == $currentpage) {
                // 'highlight' it but don't make a link
                echo " [<b>$x</b>] ";
                // if not current page...
              } // END if ($x == $currentpage)
              else {
                // make it a link
                echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>$x</a> ";
              } // END else
            } // END else
          } // END if (($x > 0) && ($x <= $totalpages))
        } // END for loop
    
        // if not on last page, show forward and last page links
        if ($totalpages == 0) {
          echo "";  }
        else{
          if ($currentpage != $totalpages) {
            // get next page
            $nextpage = $currentpage + 1;
    
            // echo forward link for next page
            echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'> › </a> ";
    
            // echo forward link for lastpage
            echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2'>›› </a> ";
          } // END if ($currentpage != $totalpages)
        }// END else
    echo "<br>currentpage=$currentpage&gender=$genderPref&genderPref=$gender&ageMin=$ageMin&ageMax=$ageMax&year1=$year1&year2=$year2";
    
    $link='currentpage=';
    $link1='&gender=';
    $link2='&genderPref=';
    $link3='&ageMin=';
    $link4='&ageMax=';
    $link5='&year1=';
    $link6='&year2=';
    $total=$link.$currentpage.$link1.$genderPref.$link2.$gender.$link3.$ageMin.$link4.$ageMax.$link5.$year1.$link6.$year2;
    $_SESSION['pages']=$total;
    echo "<br>$total";
    
    // -------- END PAGINATION --------------------------------------------
        
      } // END if ($exp_date >= $todays_date)
      else  {
        // billing has expired
        echo "Billing has expired<br>";
        echo $_SESSION['clientID'];
    
        echo "<br><a href='session2.php'>Sesssion2</a>";
        echo "<br><a href='form.php'>Form</a>";
      }
    
    
      } // END valid session
    
    ?>

     

    Change the range from:

    $range = 3;
    

     

    To:

    $range = 24;
    

     

    This will display all fifty pages of data and allow you to scroll through them. If that is not what you are going for please reiterate your problem so I can better understand.

    Thanks,

    Colton Wagner

  6. PFMaBiSmAd said that a while statement would not be needed but this whole problem could be solved in one while statement rather than multiple if statements and a loop. Just saying it could have been done a lot simpler than all this trouble your going to now.\

     

    Thanks,

    Colton Wagner

     

    Thanks for the reply. You're right, I've been going through all this pain. But I guess I found an alternative which does not require adding textboxes at runtime. I'll by default show 3 textboxes. And I found the code for implementing this in the project. Let me give it a shot.

     

    By the way Colton, I just noticed that you are only 17 and know lots of stuff already about programming. I am pleasantly surprised! :)

     

    I also own my own business in Evansville Indiana not to toot my own horn or anything. I really love this forum it picks your brain and teaches you different styles of programming. I learn a lot from the staff and other members such as yourself so I enjoy having intriguing conversations it really helps build problem solving skills.

    Thanks,

    Colton Wagner

  7. Yes, you are taking what is inside the "div" container and copying so it is doubling what it gets everytime. Instead make a while statement that increments the inputs and manually add the html.

     

    var content = "<input type=\"text\" value=\"\" name=\"member#\" />"

     

    Then number sign in the above code should be an increment variable from a while statement. This will make it so that you can add multiple members to a database in stead of having multiple members but only the last one gets submitted. You should also include at the end of the while statement a hidden value that tells the php code how many members there are so it know how to set the DB up.

     

    Thanks,

    Colton Wagner

  8. This should automatically pull up the id equivalent to 1.

     

        switch ($_GET['page']) {
            case 'news':
                if(is_numeric($id)){
                    mysql_select_db ($db, $link);
                    $query = "SELECT * from news WHERE id = '$id'";
                    $result = mysql_db_query ($db, $query, $link);
                        while ($row = mysql_fetch_array ($result)) {
                            echo ("ID $row[id] title is $row[title]<br />");
                        }
                } else {
                    $id = "1";
                    mysql_select_db ($db, $link);
                    $query = "SELECT * from news WHERE id='$id'";
                    $result = mysql_db_query ($db, $query, $link);
                        while ($row = mysql_fetch_array ($result)) {
                            echo ("ID $row[id] title is $row[title]<br />");
                        }
                }
        }
        break;

     

    Hope I could be of some help. ngreenwood6 made it so that it would display all the data in the database. I hope that could be some help.

     

    Thanks,

    Colton Wagner

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