Jump to content

wkilc

Members
  • Posts

    130
  • Joined

  • Last visited

Posts posted by wkilc

  1. Hi all,

     

    Not sure if this is a browser feature kind of thing, or if it can be done with a script.

     

    I'm looking at my page:

    www.mysite.com/index.php?start=0

     

    I scroll to the bottom of the page with the vertical scroll bar, and then click the pagation link to start on page 2, record #50:

    www.mysite.com/index.php?start=50

     

    Of course, the vertical scroll bar jumps back to the it jumps to the top of my page.

     

    Is there a way to make it remember that the scroll bar was at the bottom (or in the middle)?

     

    Thanks.

  2. I am attempting to flush values from a URL query with a pagation script.

     

    This line of code will replace one value:

    $page_name2 = preg_replace('/&?start=\d+/','',$page_name);

     

    This line of code will replace the second value:

    $page_name3 = preg_replace('/&?limit=\d+/','',$page_name);

     

    Can I combine them to replace both values in replace?

     

    This obviously isn't it:

    $page_name3 = preg_replace(('/&?limit=\d+/','',)&&('/&?start=\d+/','',)$page_name);

     

    Thank you.

     

  3. Thanks.  The idea is I want to keep all the other values in the URL while getting rid of the redundant "start".

     

    www.mysite.com?name=smith&subject=movies&start=0&limit=50

     

    When I use the form to filter it to 100 results per page, I want to purge both the start and the limit values to avoid this:

    www.mysite.com?name=smith&subject=movies&start=0&start=0&limit=100

     

    Thank you.

     

    ~Wayne

  4. This script will clear the old limit value from the URL query:

     

    <?php 
    //remove any old limits from query
    $tmp = array();
    foreach ($_GET as $fld => $val)
        if ($fld != 'limit')
             $tmp[] = $fld . '=' . $val;
    $page_name = $_SERVER['SCRIPT_NAME'] . '?' . implode('&',$tmp);
    ?>

    <form>
    <select">
    <option value="<? echo "$page_name" ?>&start=0&limit=25">25 records per page</option>
    <option value="<? echo "$page_name" ?>&start=0&limit=50">50 records per page</option>
    <option value="<? echo "$page_name" ?>&start=0&limit=100">100 records per page</option>
    </select>
    </form>

     

    How can I get it to clear BOTH the start and the limit values in the URL?

     

    Thank you.

     

    ~Wayne

  5. Howdy,

     

    The following code wil geenrate a dynamic pull-down list based on column values.

     

    Can someone help me tweak it so that is will NOT display a duplicate record value.  That is, if the sponsors values in the table were Hart, Michaels, Michaels, Morella  ...it would only display Hart, Michaels, Morella in the pull-down menu.

     

    <form name="form0">
    <? $result = @mysql_query("select distinct sponsor from table ORDER BY sponsor ASC");
    if (mysql_num_rows($result) > 0) {
      print "<select name=\"link\">"; ?>
      <option <?php if(empty($_GET['sponsor'])){ echo "selected=\"selected\""; } ?> value="<? echo "$page_name" ?>">SELECT A SPONSOR</option>
      <? while ($row = mysql_fetch_array($result)) {
        print "<option ";
        if($_GET['sponsor'] ==   $row['sponsor']  ){ echo "selected=\"selected\""; }
        print " value=\"index?sponsor=" . $row['sponsor'] . "\">" . $row['sponsor'] . "</option>\n";
      }
      print "</select>";
    } 
    ?>
    </form>

     

    Thank you.

     

    ~Wayne

  6. Hi all,

     

    I'm using a gateway for CC, when they payment is made and then users are redirected back to my site, I grab the order number and echo it as $info so I can display on the user's receipt.

     

    <?php
    $info=$_POST['OrderNo']; 
    echo "$info";
    ?>
    

     

    Is it possible to use PHP to either to automatically (onload) submit a form or somehow write $info to a text file so I can reconcile the books later?  I can do the former successfully with JavaScript... but I'd rather make it server-side.

     

    Thanks.

  7. I am dynamically bulilding a pull-down menu based on values from a table.

     

    I think what's going on here, is when the "school" value is empty (no school is listed for some records) it shows an empty gap in the pull-down menu, with no value.

     

    Is there a way to rectify this?  So far, I've just been inserting a "-" into the empty values in the table as a work around.

     

    <? $result = @mysql_query("select distinct school from table ORDER BY school ASC");
    if (mysql_num_rows($result) > 0) {
      print "<select>"; ?>
      <option <?php if(empty($_GET['school'])){ echo "selected=\"selected\""; } ?> value="<? echo "$page_name" ?>">DISPLAY ALL SCHOOLS</option>
      <? while ($row = mysql_fetch_array($result)) {
        print "<option ";
        if($_GET['school'] ==   $row['school']  ){ echo "selected=\"selected\""; }
        print " value=\"$page_name&start=0&school=" . $row['school'] . "\">" . $row['school'] . "</option>\n";
      }
      print "</select>";
    } 
    ?> 

     

    Thank you,

     

    ~Wayne

  8. Hello all,

     

    The following script is used to query an array. (www.example.com/test.php?lev[]=MS&lev[]=College)

     

    Currently, it echos the values queried and simply lists them (echo "$lev (br />\n").  Is it possible to echo those values by keeping the checkbox in question checked instead?

     

    <?php echo "<b>Levels <br /> />";
    if(!empty($_GET['lev']))
      foreach($_GET['lev'] as $lev){
        echo "$lev  <br />\n";
      } ?>
    
    <form />
    <input type="checkbox" name="lev[]" value="PreK" /><font class="sm">PreK</font>
    <input type="checkbox" name="lev[]" value="Elem" /><font class="sm">Elem</font>
    <input type="checkbox" name="lev[]" value="MS" /><font class="sm">MS</font>
    <input type="checkbox" name="lev[]" value="HS" /><font class="sm">HS</font>
    <input type="checkbox" name="lev[]" value="College" /><font class="sm">College</font>
    <input type="submit" value=" ..:: Submit ::.. " />

     

    Thank you.

     

    ~Wayne

  9. $page_name = $_SERVER["REQUEST_URI"];
    $page_name = preg_replace('/&?limit=\d+/','',$page_name);
    $page_name = preg_replace('/&?start=\d+/','',$page_name);

     

    This doesn't work for the &start= link comes out as "sub=Array" again.

     

    If I change it to this:

    $page_name = $_SERVER["REQUEST_URI"];
    $page_name = preg_replace('/&?limit=\d+/','',$page_name);
    $page_name2 = preg_replace('/&?start=\d+/','',$page_name);

     

    Then it obviously doesn't  flush &limit= anymore.

     

    I'm sorry...

     

    ~Wayne

  10. THANK YOU!!!!

     

    I was trying to simplify for the purpose of posting... the problem now is...

     

    I've got more than one value:

     

    there's also &start= which tells it if we're on the first, second, third, etc.. of the displayed pages.

     

    The idea is that I want to clear the one I'm changing while keeping the other.

    www.example.com/test.php?sub=math[]&sub[]=science&limit=50&start=50

     

    Can't do both like this, right?

     

    $page_name = $_SERVER["REQUEST_URI"];
    $page_name = preg_replace('/&?limit=\d+/','',$page_name); 
    $page_name = preg_replace('/&?start=\d+/','',$page_name);

     

    ~Wayne

  11. I tired something earlier, with no luck...  so I'm taking a few steps back.  I've been working this one complicated page for days...

     

    Here's what used to work:

     

    //the current URL
    $page_name = $_SERVER["REQUEST_URI"];
    
    //remove any old limit from query before requesting a new limit
    $tmp = array();
    foreach ($_GET as $fld => $val)
        if ($fld != 'limit')
             $tmp[] = $fld . '=' . $val;
    $page_name = $_SERVER['SCRIPT_NAME'] . '?' . implode('&',$tmp);
    
    //sets the number of records to be displayed on the page
    <form>
    <select name="link">
    <option value="<? echo "$page_name" ?>&limit=25">25 records per page</option>
    <option value="<? echo "$page_name" ?>&limit=50">50 records per page</option>
    <option value="<? echo "$page_name" ?>&limit=100">100 records per page</option>
    </select>
    </form>
    

     

    This grabs the current URL, and clears the &limit= string before a new limit is introduced to avoid:

    www.example.com/test.php?sub=math[]&sub[]=science&limit=25&limit=50&limit=100

     

    The problem, is that my URL is already querying an array:

    www.example.com/test.php?sub[]=math&sub[]=science

     

    So now, when I apply the form above to this URL set the new limit to 50 records per page the URL actually becomes:

    www.example.com/test.php?sub=Array&limit=50

    Warning: Invalid argument supplied for foreach() ... on line 147

     

    I guess I've broken the array?

     

    //line 147 
    echo "subject:<BR />";
    if(!empty($_GET['sub']))
      foreach($_GET['sub'] as $sub) {
        echo "$sub <BR />\n";
      }

     

    ~Wayne

     

  12. Just realized that there might be variables after &limit= that I would want to keep...

     

    So I'm back to:

     

    //remove any old limit from query
    $tmp = array();
    foreach ($_GET as $fld => $val)
        if ($fld != 'limit')
             $tmp[] = $fld . '=' . $val;
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . '?' . implode('&',$tmp);
    

     

    Just trying to flush the current "limit"... this has worked in other instances for me before.

     

    ~Wayne

  13. Thank you.

     

    Again, I'm pretty green...

     

    <?php
      $curPageURL = $curPageURL;
      echo stristr($curPageURL, '&limit='); // outputs ER@EXAMPLE.com
      echo stristr($curPageURL, '&limit=', true); // As of PHP 5.3.0, outputs US
    ?>

     

    gives me:

     

    Warning: Wrong parameter count for stristr()

     

    Thanks.

     

    ~Wayne

  14. I'm a noob, tring to reverse engineer some current code.

     

    This code is grabbing the current URL:

     

    <?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;
    }
    ?>

     

    This form is adding "&limit=50" to the URL, to show 25, 50 or 100 results per page:

    <form>
    <select name="link">
    <option <? echo "$select25" ?> value="<? echo curPageURL(); ?>&limit=25">25 records per page</option>
    <option <? echo "$select50" ?> value="<? echo curPageURL(); ?>&limit=50">50 records per page</option>
    <option <? echo "$select100" ?> value="<? echo curPageURL(); ?>&limit=100">100 records per page</option>
    </select>
    </form>

     

    The problem is here (I think).  This is supposed to flush the old limit before requesting a new one... but right now, I'm getting another one tacked on with each new request:

    www.website.com/members?sub[]=math&sub[]=science&lev[]=middleschool&limit=25

    www.website.com/members?sub[]=math&sub[]=science&lev[]=middleschool&limit=25&limit=50

    www.website.com/members?sub[]=math&sub[]=science&lev[]=middleschool&limit=25&limit=50&limit=100

    <?php 
    //remove any old limit from query
    $tmp = array();
    foreach ($_GET as $fld => $val)
        if ($fld != 'limit')
             $tmp[] = $fld . '=' . $val;
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] . '?' . implode('&',$tmp);
    ?>

     

    Any ideas?

     

    Thanks.

     

    ~Wayne

     

     

     

  15. I've modified the query to include:

     

       and ((user_info.PreK LIKE '%$lev%')
         or (user_info.Elem LIKE '%$lev%'))

     

    and the form looks like thus:

     

    echo "<u>level</u><BR />";
    if(!empty($_GET['lev']))
      foreach($_GET['lev'] as $lev){
        echo "$lev <BR />\n";
      }
    echo "<u>subject</u><BR />";
    if(!empty($_GET['sub']))
      foreach($_GET['sub'] as $sub){
        echo "$sub <BR />\n";
      }
    ?>
    <form action="search_advanced.php" method="get">
    <input type="checkbox" name="lev[]" value="PreK" />PreK
    <input type="checkbox" name="lev[]" value="Elem" />Elem
    <input type="checkbox" name="lev[]" value="MS" />MS
    <input type="checkbox" name="lev[]" value="HS" />HS
    <input type="checkbox" name="sub[]" value="Math" />Math
    <input type="checkbox" name="sub[]" value="Reading" />Reading
    <input type="submit" value="submit" />
    </form>

     

    But... was you said, it's overwriting:

    advanced.php?lev[]=PreK&lev[]=Elem

     

    ...the above URL only gives me Elem, no PreK.

     

    ~Wayne

  16. Thank you!

     

    But now the URL contains []

     

    ?level=PreK[]&level=Elem[]&level=MS[],

     

    ...which prevents the link from working.

     

    Is there a way to remove that but still allow it to echo the variables filtered?

     

    I'm very new to this... do I need to define the array here as well?

     

    Thanks again.

     

    ~Wayne

  17. Can someone help me code kind of a "advanced search" form, that will get a URL:

     

    <form method="get">
    <input type="checkbox" name="level" value="PreK" />
    <input type="checkbox" name="level" value="Elem" />
    <input type="checkbox" name="level" value="MS" />
    <input type="checkbox" name="level" value="HS" />
    <input type="checkbox" name="subject" value="Math" />
    <input type="checkbox" name="subject" value="Reading" />
    <input type="checkbox" name="level" value="Science" />
    <input type="submit" value="submit" />
    </form>

     

    So... if I ticked PreK, Elem and Math, the resulting link would be:

    www.mysite.com?level=PreK&Elem&subject=Math

     

    The most complicated thing... how would I get place the "&" in between variables?

     

    Thank you once again.

     

    ~Wayne

     

     

     

  18. Something like this?  (I say like this... because I've done something wrong ...and this gives me an error.)

     

            WHERE ((user_info.Type LIKE '$Type%')
                    and ((user_info.snr_First LIKE '%$name%')
                    or (user_info.snr_Last LIKE '%$name%'))
         		and (user_info.snr_Home_phone LIKE '$snr_Home_phone%')
       		and (user_info.snre_eMail LIKE '$snre_eMail%')
       		and ((user_info.PreK LIKE '$levels%')
    	or (user_info.Elem LIKE '$levels%')
    	or (user_info.MS LIKE '$levels%')
    	or (user_info.HS LIKE '$levels%')
    	or (user_info.College LIKE '$levels%')
            or (user_info.Admin LIKE '$levels%')
                    or (user_info.Prvt LIKE '$levels%'))
                    and (user_info.PreK AND user_info.Elem LIKE '$primary%'))
            	ORDER BY user_info.$sort LIMIT $eu, $limit ";
    $result = mysql_query($query);

     

    Thanks.

     

    ~Wayne

     

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