Jump to content

techker

Members
  • Posts

    812
  • Joined

  • Last visited

Posts posted by techker

  1. hey guys i have this script i found it works in all but it does not link to page 2?it shows like 10 results on 2 pages bu the second page is not there?

     

    <? //---------------------------------------------------------------------------------------
    ////////////////////////////////////////////
    //  PAGINATION FUNCTION  //
    //  by: Karl Steltenpohl          //
    ////////////////////////////////////////////
    $con = mysql_connect("localhost","t","k"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("techker_softcore", $con);
    
    
    
    function pagination($table, $order, $searchstring, $pre, $pos, $nav, $page, $pages)
    {
    ///////////////////////
    //  Get Current Url  //
    ///////////////////////
    $webpage = basename($_SERVER['PHP_SELF']);
    global $webpage;
    
    ////////////////////////
    //  Sorter and Pagination Query Begin  //
    /////////////////////////////////////////
    //$pre = $_REQUEST['pre'];
    //$pos = $_REQUEST['pos'];
    //$nav = $_REQUEST['nav'];
    //$page = $_REQUEST['page'];
    //$pages = $_REQUEST['pages'];
    
    
    ///////////////////////////////////////////
    //  Set Initial Pre Pos and Page Limits  //
    ///////////////////////////////////////////
    if($pre == "" and $pos == "" and $page == "")
    {
    $pre = 0;
    $pos = 9;
    $page = 1;
    }
    
    
    ///////////////////////////////
    //  User Navigates Previous  //
    ///////////////////////////////
    if($nav == "prev")
    {
    $pre = ($pre - 10);
    $pos = ($pos - 10);
    $page = ($page - 1);
    }
    
    
    ///////////////////////////
    //  User Navigates Next  //
    ///////////////////////////
    if($nav == "next")
    {
    $pre = ($pre + 10);
    $pos = ($pos + 10);
    $page = ($page + 1);
    }
    
    
    /////////////////////////////
    //  If page number to low  //
    /////////////////////////////
    if($page < 1)
    {
    $pre = 0;
    $pos = 9;
    $page = 1;
    }
    
    //////////////////////////////
    //  If page number to high  //
    //////////////////////////////
    if($page > $pages)
    {
    $pre = 0;
    $pos = 9;
    $page = 1;
    }
    
    
    //////////////////////////////////////////
    //  Select for total number or results  //
    //////////////////////////////////////////
    $r = "SELECT DISTINCT * FROM $table $searchstring";
    $re = mysql_query($r) or die("error 12547");
    $nums = mysql_num_rows($re);
    
    
    ////////////////////////////////////////////
    //  Select for current displayed results  //
    ////////////////////////////////////////////
    $request = "SELECT DISTINCT * FROM $table $searchstring ORDER BY $order DESC LIMIT $pre, 10";
    $result = mysql_query($request) or die("error 25352");
    $num = mysql_num_rows($result);
    
    
    ///////////////////////////////////////
    //  Determine total number of pages  //
    ///////////////////////////////////////
    $pages = ceil($nums/10);
    
    
    /////////////////////////////////
    //  Create Navigation Display  //
    ///////////////////////////////// 
    $navigation = "
    $nums entries on $pages Page(s)<br>
    <a href=\"$webpage?page=$page&nav=prev&pre=$pre&pos=$pos&pages=$pages&view=view\">Previous</a> |
    Page $page |
    <a href=\"$webpage?page=$page&nav=next&pre=$pre&pos=$pos&pages=$pages&view=view\">Next</a><br>
    Results $pre - $pos
    ";
    
    /////////////////////////////////
    //  Create Paginagtion Array   //
    /////////////////////////////////
    // result is the result of the limited query
    $pagination = array($navigation, $result, $num);
    
    
    /////////////////////////////////
    //  Return Paginagtion Array   //
    /////////////////////////////////
    return $pagination;
    }//end function
    
    
    
    //--------------------------------------------------------------------------------------------
    //Here is an example of how to impliment it
    //------------------------------------------------------------------------------------------
    
    //this is the search string to the sql db
    $searchstring = "WHERE `type` = 'sketch'";
    
    //this is the table being searched
    $table = "softcore";
    
    //this is the table field to order the results by
    $order = "id";
    
    // call the function
    $pagination = pagination($table, $order, $searchstring, $pre, $pos, $nav, $page, $pages);
    
    //this pulls out the display
    $navigation = $pagination[0];
    
    //this pulls out the results
    $result = $pagination[1];
    
    //this pulls out the num of results
    $num = $pagination[2];
    
    //echo the display onto the site
    while ($row = mysql_fetch_array($result)) 
    	{
    
    	 echo '<th scope="row"><a href="/admin/art/'. $row['pic'] .'" target="_blank" >
    <img src="/admin/imgsize.php?w=60&h=50&img=art/'. $row['pic'] .'" border="0" alt="" />
    </a>
    <th />'; 
    
    	}
    echo"<br>$navigation</br>";
    
    //now all you need to do is loop the result based on the num
    //each page will display 10 results.?>
    

     

    link:http://softcoredesign.com/test2.php?page=1&nav=next&pre=0&pos=9&pages=2&view=view

  2. hey guys i have an event calendar script that insert in a databse the event like so:

     

      id  uid  m  d  y  start_time  end_time  title  text 

     

    now i want to do some stats on my maine page.

     

    like upcomming event,# of evevent in the week and month..

     

    so my questions i got the day

     

    SELECT `d` 
    FROM pec_mssgs
    WHERE `d` >= day( curdate( ) ) 
    LIMIT 0 , 30 
    

    how can i select the week?

  3. hey guys i have this list box that selects from a database.

     

    as is it only selects the first name.i need it to select both first and last name?

     

    $link = mysql_connect("localhost", "techker_techker", "techker");
    mysql_select_db("techker_trainerstool");
      
    $query = "SELECT client_first FROM trainers_clients";
    $result = mysql_query($query);
    
    print "<SELECT name=client>";
    while ($line = mysql_fetch_array($result))
    
    {
    foreach ($line as $value)
    
    {
    
    print "<OPTION value='$value'";
    }
    print ">$value</OPTION>";
    }
    
    
    mysql_close($link);
    print "</SELECT>";
    

     

    i have tryed:

     

    adding another query for last name.but showed first name on one line then last on another line..

     

    select client_fisrt,client_last from...(did not work,only showed the first name)

     

    select (client_fisrt,', ',client_last) no success same as the other

     

    i have tryed lots more combos but no succes or error messages?

     

    is there a way to do it?

  4. All you need do is concatinate it into your query. eg;

     

    $sql = "SELECT * FROM foo WHERE username = '" . $check['name'] ."'";

     

    Or imbed it directly within a double quoted string....

     

    $sql = "SELECT * FROM foo WHERE username = '{$check['name']}'";

     

    thxclose but no cigar..  " . $check['name'] ." i forgot the"'"

     

    what is this called so i can can study on this?

     

     

  5. ok..if i can't find the original $check var..then i want to use it.Can i intergrate it then?

     

    $check['name']

     

    in

    another variable that i can make?

     

    and in a query ?

     

    $fileSQL=" SELECT *

    FROM `trainers_clients`

    WHERE `trainer` = $check['name'] ////here

    LIMIT 0 , 30 ";

    $fileLIST=mysql_query($fileSQL);

     

  6. see my client is using login manager.in a page there is the includes.

     

    so all the variable are alredy done.

     

    like this $check =$CheckSecurity->page_check($USERNAME, $PASSWORD,$dbhost,$dbusername,$dbpass,$dbname);

     

    so when i do $check['name'] it gives me the client login name.

     

    now i need to create a variable that will include the client login name.

     

    $documents=Scheck['name']

  7. hey guys in my script i used session and when a client logs in it shows his name

     

    <? echo $check['name']; ?>
    

     

    i need to make a config page and i whant to do a variable that will eco the username

    i have tryed this but no success

    $trainer=$check['name'];

  8. hey guys i have a math prob here..

     

    i need to do a body fat calculator..

     

    i have the number

     

    Body Fat Formula For Men

    Factor 1 (Total body weight x 1.082) + 94.42

    Factor 2 Waist measurement x 4.15

    Lean Body Mass Factor 1 - Factor 2

    Body Fat Weight Total bodyweight - Lean Body Mass

    Body Fat Percentage (Body Fat Weight x 100) / total bodyweight

     

    i need to put it in a form like here  http://www.bmi-calculator.net/body-fat-calculator/

     

    i have no clue how to do math with php?

     

    sorry i found it in javascript.

     

    http://javascript.about.com/library/blfat2.htm

     

    thx anyways..

  9. ok i got it going i remove the " " cause it was giving me a white space error..

     

    <? 
    // Connects to your Database
    mysql_connect("localhost", "l_l", "l") or die(mysql_error());
    mysql_select_db("techker_l") or die(mysql_error());
    
    $id = mysql_escape_string($_GET['id']);
    $q = "SELECT * FROM cardio_select WHERE id = '$id'";
    $res = mysql_query($q);
    $row = mysql_fetch_assoc($res);
    
    
    $plan =$row['simple'];
    $plan2 =$row['combo'];
    
    
    if ( $plan == "on" ) {
    echo "<meta http-equiv=Refresh content=2;url=client_cardio.php>";;
    }
    elseif($plan2 == "on"){
    echo "<meta http-equiv=Refresh content=2;url=emplacement.php>";;
    } 
    ?>
    

     

    is this the write way to do it?

  10. sorry fergot to post it..lol

     

    ok so i have 2 questions in this:

    <? 
    // Connects to your Database
    mysql_connect("localhost", "l", "techker") or die(mysql_error());
    mysql_select_db("techker_llls") or die(mysql_error());
    
    $id = mysql_escape_string($_GET['id']);
    $q = "SELECT * FROM cardio_select WHERE id = '$id'";
    $res = mysql_query($q);
    $row = mysql_fetch_assoc($res);
    
    
    
    $plan = "$row['simple']";      //is this ok?will it get table simple?
    $plan2 = "$row['combo']";
    
    if ( $plan == "on" ) {;         //if that table's value is on then it should get page x
    }
    elseif($plan2 == "on"){;       //if this one is on then it gets  page b
    } 
    ?>
    

     

    now it's the getting that page the part were i freeze..

     

    i was looking at fetch but i think it is only for arays.

     

    then i looked at another page i did and the echo

    echo "<meta http-equiv=Refresh content=4;url=emplacement.php>";

     

    but was woundering if 2 would the script get confused?

  11. hey guys i have a script that selects client from a databse.now that client is either in a programme simple or combo.

     

    there is a link on that page that gets a grid with exercises on it.

     

    now i need a script between that process thats like if the client is simple fetch page...if client is combo fetch page x..

  12. hey guys i want to to a picture gallery for my cuz.now i made an admin section to upload the pics and it inserts the name and description in a database..

     

    now when i use a php echo witha select all pics from..

     

    it shows all the pics put in one straight line..

     

    is there a way to make it show like 4 images per row..

     

    pic  pic  pic  pic

    pic  pic  pic  pic

     

     

    http://www.humanflytattoo.com/tattoo.php  (like this)

  13. first off i ma not sure if you mean radio instead of check boxes but in anycase you have 2 problems

    1. you requesting $_POST['pic']; which is the ID not the name.. the name is "select"

    2. it will only take the last ticked value..

     

    so to fix this.. change

    <input type="checkbox" name="select" id="pic" value='<? $row['name'] ?>'/>

    to

    <input type="checkbox" name="pic[]" id="pic" value='<?php $row['name'] ?>'/>

     

    and then

    change

    $pic=$_POST['pic'];
    

    to

    $pic=$_POST['pic'][0]; //assuming you only tick 1 box
    

     

    so what would be the value?i need the named of the image that is ticked.

    whats the [0] added?

  14. hey guys im trying to do a select pic to insert the name in a database.

     

    the insert works but it does not insert the pic name only an id..

     

    i can't seem to figure it out..

     

    <? $dbh = mysql_connect("localhost","user","pass") or die("There was a problem with the database connection.");
        $dbs = mysql_select_db("db", $dbh) or die("There was a problem selecting the categories.");
    
    $type=$_POST['type'];
    
    
    $sql = "SELECT * 
    FROM `gymball` 
    WHERE `type` = '$type' ";
    $fileLIST=mysql_query($sql);?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GymGraph</title>
    </head>
    
    <body>
    
    
    <p align="center"><u>Sélectionner UNE photo</u></p>
    <table width="346" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr><? while($row = mysql_fetch_array($fileLIST)) { ?>
        <td width="173"><?php echo '<a href="/Gymgraph/Gymgraph/gymball/'. $row['name'] .'" target="_blank">
    <img src="/Gymgraph/Gymgraph/gymball/'. $row['name'] .'" border="0" alt="" width=115/>
    </a> 
    <br />'; ?></td>
        <td width="173"><label>
          <input type="checkbox" name="select" id="pic" value='<? $row['name'] ?>'/>
        Selection de photo</label></td>
      </tr>
      <? } ?>
    </table>
    <p>
      <p>
        <label>
        <div align="center">
          <select name="location" id="location">
            <option value="pic1">1</option>
            <option value="pic2">2</option>
            <option value="pic3">3</option>
            <option value="pic4">4</option>
            <option value="pic5">5</option>
            <option value="pic6">6</option>
            <option value="pic7">7</option>
            <option value="pic8">8</option>
          </select> 
          Emplacement de la photo
        </div>
        </label>
      </p>
      <label>
      <div align="center">
        <input type="submit" name="submit" id="submit" value="Submit" />
      </div>
      </label>
      <div align="center">  Envoyer la sélection
      </div>
    </p>
    </form>
    </body>
    </html>
    

     

    and this is the insert pic

    <?php

     

    $pic=$_POST['pic'];

    $location=$_POST['location'];

     

     

     

    mysql_connect("localhost", "user", "t") or die(mysql_error()) ;

    mysql_select_db("techker_gymgraphpics") or die(mysql_error()) ;

     

     

     

    //Writes the information to the database

    mysql_query("INSERT INTO $location (name) ".

            "VALUES ('$pic')");

     

     

    //Tells you if its all ok

    $id= mysql_insert_id();

        echo "<p>This file has the following Database ID: <b>$id</b>";

    echo "You'll be redirected to Home Page after (4) Seconds";

              echo "<meta http-equiv=Refresh content=4;url=gymball_select.php>";

     

    ?>

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