Jump to content

PCurry

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

PCurry's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. or, alternatively, is there a better way to validate that the user has selected at least one of the dropdowns?
  2. I have 2 dropdowns, both default to 'select'. The query seemed to work ok before I added validation that both dropdowns need to have a value other than 'select' before the query will be run (i.e., "please select a value for both dropdowns"). For one of the dropdowns, the value just prior to that evaluation has a value/year selected, but within that IF evaluation it echos as 'select'. --right before IF--year:2010 post year:2010 year end:2011 owner:C WAGNER ------while in IF--year:select post year:2010 year end:2011 owner:C WAGNER the code is up at brewhas.org/team_history.php any ideas as to why that value seems to change within the IF? <?php $url_owner = $_GET['owner']; $url_year = $_GET['year']; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Brewhas Keeper League Fantasy Baseball - Team Transaction History</title> <link rel="stylesheet" type="text/css" href="style/bklstyle.css" /> <link rel="stylesheet" type="text/css" href="style/mm_travel2.css" /> <link rel="shortcut icon" href="http://www.brewhas.org/images/favicon.ico"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="#003300"> <td rowspan="2" nowrap="nowrap" bgcolor="#003300"> </td> <td width="59" rowspan="2" nowrap="nowrap" bgcolor="#003300"><img src="http://www.brewhas.org/images/BKL.jpg" alt="BKLLogo" width="59" height="66"/></td> <td width="608" height="49" align="center" valign="bottom" nowrap="nowrap" bgcolor="#003300" id="logo"><span class="style1">BREWHAS KEEPER LEAGUE </span></td> <td width="415" align="center" valign="bottom" nowrap="nowrap" bgcolor="#003300" id="logo"> </td> <td width="5" rowspan="2" bgcolor="#003300"> </td> </tr> <tr bgcolor="#003300"> <td height="24" align="center" valign="top" bgcolor="#003300" id="tagline"><span class="style2">fantasy baseball</span></td> <td height="24" align="center" valign="top" bgcolor="#003300" id="tagline"> </td> </tr> <tr> <td colspan="6" bgcolor="#003300"><img src="images/mm_spacer.gif" alt="" width="1" height="1" border="0" /></td> </tr> <tr bgcolor="#CCC999"> <td height="15" colspan="5" bgcolor="#CCC999"> <div class="container"> <div style="clear: both; display: block; padding-bottom: 2px;"></div> <ul id="topnav"> <li><a href="http://www.brewhas.org/index.html">Home</a></li> <li><a href="#">Team Pages</a> <span> <a href="http://www.brewhas.org/team_pages/boothby.html">Boothby</a> | <a href="http://www.brewhas.org/team_pages/bradt.html">Bradt</a> | <a href="http://www.brewhas.org/team_pages/jcurry.html">J Curry</a> | <a href="http://www.brewhas.org/team_pages/pcurry.html">P Curry</a> | <a href="http://www.brewhas.org/team_pages/hurlebaus.html">Hurlebaus</a> | <a href="http://www.brewhas.org/team_pages/jankowski.html">Jankowski</a> | <a href="http://www.brewhas.org/team_pages/oneil.html">O'Neil</a> | <a href="http://www.brewhas.org/team_pages/shimizu.html">Shimizu</a> | <a href="http://www.brewhas.org/team_pages/cwagner.html">C Wagner</a> | <a href="http://www.brewhas.org/team_pages/jwagner.html">J Wagner</a> </span> </li> <li><a href="http://www.brewhas.org/rules.html">League Rules</a></li> <li><a href="http://www.brewhas.org/payout_picks.html">Payouts & Draft Order</a></li> <li><a href="http://www.brewhas.org/standings/2010_standings.html">Standings</a> <span> <a href="http://www.brewhas.org/standings/2010_standings.html">2010</a> | <a href="http://www.brewhas.org/standings/2009_standings.html">2009</a> | <a href="http://www.brewhas.org/standings/2008_standings.html">2008</a> | <a href="http://www.brewhas.org/standings/2007_standings.html">2007</a> | <a href="http://www.brewhas.org/standings/2006_standings.html">2006</a> | <a href="http://www.brewhas.org/standings/2005_standings.html">2005</a> | <a href="http://www.brewhas.org/standings/2004_standings.html">2004</a> | <a href="http://www.brewhas.org/standings/2003_standings.html">2003</a> | <a href="http://www.brewhas.org/standings/2002_standings.html">2002</a> | <a href="http://www.brewhas.org/standings/2001_standings.html">2001</a> </span> </li> <li><a href="http://www.brewhas.org/drafts/2011_draft.html">Drafts</a> <span> <a href="http://www.brewhas.org/drafts/2011_draft.html">2011</a> | <a href="http://www.brewhas.org/drafts/2010_draft.html">2010</a> | <a href="http://www.brewhas.org/drafts/2009_draft.html">2009</a> | <a href="http://www.brewhas.org/drafts/2008_draft.html">2008</a> | <a href="http://www.brewhas.org/drafts/2007_draft.html">2007</a> | <a href="http://www.brewhas.org/drafts/2006_draft.html">2006</a> | <a href="http://www.brewhas.org/drafts/2005_draft.html">2005</a> | <a href="http://www.brewhas.org/drafts/2004_draft.html">2004</a> | <a href="http://www.brewhas.org/drafts/2003_draft.html">2003</a> | <a href="http://www.brewhas.org/drafts/2002_draft.html">2002</a> | <a href="http://www.brewhas.org/drafts/2001_draft.html">2001</a> </span> </li> <li><a href="http://www.brewhas.org/excelfiles/alltimeaverages.xls">Records</a></li> <li><a href="http://www.brewhas.org/excelfiles/transactions.xls">Transactions</a></li> </ul> </div> </td> </tr> <tr> <td width="164" bgcolor="#FFFFFF"> </td> <td width="59" bgcolor="#FFFFFF"> </td> <td colspan="4" valign="top" bgcolor="#FFFFFF"> <table border="0" cellspacing="0" cellpadding="2" width="835"> <div align="center"> <tr> <td width="831" height="31" class="pageName"> <div align="left"></div> </td> </tr> </div> </table> </td> </tr> </table> <div id="header"></div> <div id="leftcol_long"></div> <div id="content_long"> <h2>Transaction Search - Team History</h2> <table border="0" cellspacing="0" cellpadding="1" width="95%" align=center> <tr> <td bgcolor="#ffffff" height="35" valign="top" rowspan="2"> <form name="form1" method="post" action="http://brewhas.org/team_history.php"> <table border="0" align=left> <tr> <td>Year: <select name='year'> <option value='select'>SELECT</option> <option value='2011' <?php if($_POST['year'] == '2011') echo "selected"?>>2011</option> <option value='2010' <?php if($_POST['year'] == '2010') echo "selected"?>>2010</option> <option value='2009' <?php if($_POST['year'] == '2009') echo "selected"?>>2009</option> <option value='2008' <?php if($_POST['year'] == '2008') echo "selected"?>>2008</option> <option value='2007' <?php if($_POST['year'] == '2007') echo "selected"?>>2007</option> <option value='2006' <?php if($_POST['year'] == '2006') echo "selected"?>>2006</option> <option value='2005' <?php if($_POST['year'] == '2005') echo "selected"?>>2005</option> <option value='2004' <?php if($_POST['year'] == '2004') echo "selected"?>>2004</option> <option value='2003' <?php if($_POST['year'] == '2003') echo "selected"?>>2003</option> <option value='2002' <?php if($_POST['year'] == '2002') echo "selected"?>>2002</option> <option value='2001' <?php if($_POST['year'] == '2001') echo "selected"?>>2001</option> </select> Owner: <select name='owner'> <option value='select'>SELECT</option> <option value='J BOOTHBY'<?php if($_POST['owner'] == 'J BOOTHBY') echo "selected"?>>J BOOTHBY</option> <option value='K BRADT' <?php if($_POST['owner'] == 'K BRADT') echo "selected"?>>K BRADT</option> <option value='J CURRY' <?php if($_POST['owner'] == 'J CURRY') echo "selected"?>>J CURRY</option> <option value='P CURRY' <?php if($_POST['owner'] == 'P CURRY') echo "selected"?>>P CURRY</option> <option value='R HURLEBAUS' <?php if($_POST['owner'] == 'R HURLEBAUS') echo "selected"?>>R HURLEBAUS</option> <option value='M JANKOWSKI' <?php if($_POST['owner'] == 'M JANKOWSKI') echo "selected"?>>M JANKOWSKI</option> <option value='T ONEIL' <?php if($_POST['owner'] == 'T ONEIL') echo "selected"?>>T ONEIL</option> <option value='C WAGNER' <?php if($_POST['owner'] == 'C WAGNER') echo "selected"?>>C WAGNER</option> <option value='J WAGNER' <?php if($_POST['owner'] == 'J WAGNER') echo "selected"?>>J WAGNER</option> <option value='J BADER' <?php if($_POST['owner'] == 'J BADER') echo "selected"?>>J BADER</option> <option value='M SUH' <?php if($_POST['owner'] == 'M SUH') echo "selected"?>>M SUH</option> </select> </td> <td nowrap class="row1" width="40"><input type="submit" value="Submit" name="submit"></td> <td nowrap class="row1" width="60"></td> <td><p><img src="images/baseball.jpg" alt="baseball" width="8""height=8"" /><span class="style7"> Note: For the 2001 season, only the draft transactions are available.</span></p></td> </tr> </table> </form> </td> </tr> </table> <?php include 'config.php'; include 'opendb.php'; //Include the PS_Pagination class include('ps_pagination.php'); if((isset($url_year))&&(isset($url_owner))) { //If a year and owner appear in the URL, meaning we're past page 1 --> get the year and owner from the URL parms $year_search = $url_year; $owner_search = $url_owner; } else //If a year and owner have not been entered and do not appear in the URL (first time thru) --> get them from the form { $year_search = $_POST['year']; $owner_search = $_POST['owner']; } switch ($year_search) { case "2011": $year_end="2012"; break; case "2010": $year_end="2011"; break; case "2009": $year_end="2010"; break; case "2008": $year_end="2009"; break; case "2007": $year_end="2008"; break; case "2006": $year_end="2007"; break; case "2005": $year_end="2006"; break; case "2004": $year_end="2005"; break; case "2003": $year_end="2004"; break; case "2002": $year_end="2003"; break; case "2001": $year_end="2002"; break; } echo "--right before IF--"; echo "year:".$year_search." "; echo "post year:".$_POST['year']." "; echo "year end:".$year_end." "; echo "owner:".$owner_search." "; //This checks to see if both the year and the owner have been selected. if(($year_search="select")||($owner_search="select")) { echo "<BR>"."------while in IF--"; echo "year:".$year_search." "; echo "post year:".$_POST['year']." "; echo "year end:".$year_end." "; echo "owner:".$owner_search; echo "<p class='style7'>Please select both a year and a team owner.</p>"; exit; } else //sets the query to get the number of rows { $sql = "SELECT * FROM `BKL_TRANSACTIONS` WHERE (((TO_OWNER='$owner_search')OR(FROM_OWNER='$owner_search')) and (TRANS_DT >='$year_search') AND (TRANS_DT <='$year_end'))"; } $count = mysql_query($sql) or die ("Could not execute the query"); //executes the query to count the number of matching rows //Count the number of results $numrows=mysql_num_rows($count); echo "<p class='style7'>Your search: "".$year_search." ".$owner_search."" returned <b>".$numrows."</b> results.</p>"; //Count the number of results /* * Create a PS_Pagination object * * $conn = MySQL connection object (defined in opendb.php) * $sql = SQl Query to paginate * 50 = Number of rows per page * 5 = Number of links * "year=valu1&owner=value2" = Append name parameters ($year_search and $owner_search) to paginations links */ $pager = new PS_Pagination($conn, $sql, 50, 5, "year=$year_search&owner=$owner_search"); /* * The paginate() function returns a mysql result set * or false if no rows are returned by the query */ $rs = $pager->paginate(); //executes the query if(!$rs) die(mysql_error()); if ($numrows == 0) //if no matches, don't display the table exit; else //build the table and insert rows { echo "<table border=1 cellspacing=0 cellpadding=1 width='77%' align=left bordercolor=#666666>"; echo "<tr bgcolor=#cccc99 class='style5'><th width='10%' class='style5'>Date</th>"; echo "<th width='10%' class='style5'>Action</th>"; echo "<th width='12%' class='style5'>From</th>"; echo "<th width='12%' class='style5'>To</th>"; echo "<th width='5%' class='style5'>Pos</th>"; echo "<th width='18%' class='style5'>Name</th>"; echo "<th width='5%' class='style5'>Round</th></tr>"; while ($row = mysql_fetch_array($rs)) { echo "<tr><td width='10%' class='style6'>".$row['TRANS_DT']."</td>"; echo "<td width='10%' class='style6'>".$row['TRANS_ACTION']."</td>"; echo "<td width='12%' class='style6'>".$row['FROM_OWNER']."</td>"; echo "<td width='12%' class='style6'>".$row['TO_OWNER']."</td>"; echo "<td width='5%' class='style6'>".$row['POSITION']."</td>"; echo "<td width='18%' class='style6'>".$row['PLAYER_FNAME']." ".$row['PLAYER_LNAME']."</td>"; echo "<td width='5%' class='style6'>".$row['DRAFT_RND']."</td></tr>"; } //Display the navigation if ($numrows > 50) { echo "<p class='style7'>".$pager->renderFullNav()."</p>"; } echo "</table>"; } ?> </div> <div id="rightcol_long"></div> <div id="footer"><p align="center" class="style8">Brewhas Keeper League - <img src="images/icon_mlb.gif" alt="mlb" width=36 height=18> - Established 2001</p></div> <p></p> </body> </html>
  3. Never mind - got it working by getting the parms from the URL and setting the search names to those in that case. From what I've read the downside is security but it's not like I'm dealing with international trade secrets on my site, so it should work fine. Thanks Litebearer for pointing me to that script.
  4. changed the session section back to a register session_register('fnamesearch'); session_register('lnamesearch'); so it goes thru the part of the code below where the echo says the session has been set, but the session variable still does not have a value at any point (before or after this logic, before or after submitting the form. echo "before session var = ".$_SESSION['lnamesearch']; $trimmed_session = trim($_SESSION['lnamesearch']); echo "trimmed session = ".$trimmed_session; if(!isset($_SESSION['lnamesearch'])) { //Get the values from the text boxes $fnamesearch = $_POST["fnamesearch"]; $lnamesearch = $_POST["lnamesearch"]; echo "session was not set"; echo "lnamesearch=".$lnamesearch; $_SESSION['fnamesearch'] = $fnamesearch; $_SESSION['lnamesearch'] = $lnamesearch; echo "session now=".$_SESSION['lnamesearch']; } else { $fnamesearch = $_SESSION['fnamesearch']; $lnamesearch = $_SESSION['lnamesearch']; echo "session was set"."</br>"; echo "session =".$_SESSION['lnamesearch']."</br>"; echo "lnamesearch=".$lnamesearch; } can anyone tell what is going on?
  5. Ok, I've played around with this and stumped myself again. so I set the session variables and started a session <?php session_start(); // define names as session variables $_SESSION['fnamesearch']; $_SESSION['lnamesearch']; ?> and I'm trying to check if the session variables are set. If they are not, I want to grab the input and set the session variables with it. If they are set, then I want to use the session variable rather than grabbing a blank from the form (at least til I hit the point where I want to conduct another search - i'll figure that out later) if(!isset($_SESSION['lnamesearch'])) { //Get the values from the text boxes $fnamesearch = $_POST["fnamesearch"]; $lnamesearch = $_POST["lnamesearch"]; echo "session was not set"; echo "lnamesearch=".$lnamesearch; $_SESSION['fnamesearch'] = $fnamesearch; $_SESSION['lnamesearch'] = $lnamesearch; echo "session now=".$_SESSION['lnamesearch']; } else { $fnamesearch = $_SESSION['fnamesearch']; $lnamesearch = $_SESSION['lnamesearch']; echo "session was set"."</br>"; echo "session =".$_SESSION['lnamesearch']."</br>"; echo "lnamesearch=".$lnamesearch; } but when i come thru this logic, I always get "session was set" but no values in either the session variable or the $lnamesearch variable. I also played around with trying to trim it and checking if it was null, but the same results. Have I set up the session variables correctly?
  6. Thanks - yeah that's what I got out of your prev post, so I've been working through it. But I'm a bit confused as to the timing. So I've looked around and I see that before the HTML starts I need to start a session, and I can register the two session variables there: session_start(); // store names as session data session_register('fnamesearch'); session_register('lnamesearch'); Then on my initial pg, I have the two text boxes where I want to use the input to set those two session variables: $fnamesearch = $_POST["fnamesearch"]; $lnamesearch = $_POST["lnamesearch"]; $_SESSION['fnamesearch'] = $fnamesearch; $_SESSION['lnamesearch'] = $lnamesearch; But then I'm a bit confused as to what happens on subsequent pages. When the 2nd page loads, the text boxes will be empty and won't it populate the session variables with blanks, resulting in what's happening now (basically no filter and all rows returned)? I could add something to say if those session variables are populated then don't get the values from the text box, if(!isset($_SESSION['lnamesearch'])){ } else { $fnamesearch = $_POST["fnamesearch"]; $lnamesearch = $_POST["lnamesearch"]; } but then I couldn't conduct another search within the same session. I'm sure I'm missing something, probably very easy.
  7. So I think I have implemented this - part of the way (brewhas.org/transactions.php). I have two text boxes on my initial page to get a fname and lname, and they are part of my WHERE clause. I set those with $fnamesearch = $_POST["fnamesearch"]; $lnamesearch = $_POST["lnamesearch"]; (I removed validation to check for 2 chars for now). and I am passing those as parms in the URL (i.e. http://brewhas.org/transactions.php?page=2&param1=F&param2=ROD) but on that second page, it doesn't seem to be part of the WHERE clause (results go from 25 to 6440 = all recs in the db). do I need to do something like if it's p1 get them as above, if subsequent pgs do a get from the URL?
  8. thanks litebearer - that does look like a much cleaner and easy to plug in solution. so if I define the "pager" $pager = new PS_Pagination($conn, $sql, 10, 5, "param1=valu1&param2=value2"; then this call to the paginate function $rs = $pager->paginate(); if(!$rs) die(mysql_error()); replaces the standard $result = mysql_query($sql) or die ("Could not execute the query"); correct?
  9. Hi, my page is currently up at brewhas.org/transactions.php. When I retrieve a set of results > the defined # per page (such as entering 'WI' for last name), I see the first page correctly, and see the links to next pages, but when I go to the next page there are no results displayed. Same for p.3, etc. So I've looked around enough to know that I need to pass a variable to the subsequent pages, either via a session variable or the URL. I have 2 fields input on the form, as well as a limit and offset. My questions are 1) do I need to pass all 4 and if so then should I use a session variable so the URL does not get too long, and 2) can anyone provide any help with setting session variables and including them to be passed? I'm a newbie and have grabbed some code where I can but this is where i'm stuck. thanks in advance. <?php include 'config.php'; include 'opendb.php'; $rows_per_page = 20; //Get the values from the text boxes $fnamesearch = $_POST["fnamesearch"]; $lnamesearch = $_POST["lnamesearch"]; //These trim and convert the name fields to upper case. $fnamesearch=strtoupper($fnamesearch); $lnamesearch=strtoupper($lnamesearch); $fnamesearch=trim($fnamesearch); $lnamesearch=trim($lnamesearch); // Count how many rows are coming back for the query //This checks to see if there are at least 2 chars in the last name. if (strlen($lnamesearch)<2) { echo "<p class='style7'>Please enter at least 2 letters of the last name.</p>"; exit; } else //sets the query to get the number of rows { $query = "SELECT COUNT(*) FROM BKL_TRANSACTIONS WHERE((PLAYER_LNAME LIKE '$lnamesearch%')& (PLAYER_FNAME LIKE '$fnamesearch%'))"; } $result = mysql_query($query) or die ("Could not execute the query"); //executes the get count query $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; echo "count: ".$numrows; $lastpage = ceil($numrows/$rows_per_page); //determines how many pages based on rows divided by rows per page echo "pages: ".$lastpage; // Get required page number. If not present, default to 1. if (isset($_GET['pageno']) && is_numeric($_GET['pageno'])) {$pageno = $_GET['pageno']; } else {$pageno = 1; } //Checks that the value of $pageno is an integer between 1 and $lastpage. $pageno = (int)$pageno; if ($pageno > $lastpage) {$pageno = $lastpage; } if ($pageno < 1) {$pageno = 1; } //constructs OFFSET for the sql SELECT statement $offset = ($pageno - 1) * $rows_per_page; //This checks to see if there are at least 2 chars in the last name. if (strlen($lnamesearch)<2) { echo "<p class='style7'>Please enter at least 2 letters of the last name.</p>"; exit; } else //sets the query to get the number of rows { $query = "SELECT * FROM BKL_TRANSACTIONS WHERE((PLAYER_LNAME LIKE '$lnamesearch%')& (PLAYER_FNAME LIKE '$fnamesearch%')) LIMIT $offset, $rows_per_page"; } $result = mysql_query($query) or die ("Could not execute the query"); //executes the query //Count the number of results $numrows=mysql_num_rows($result); echo "<p class='style7'>Your search: "".$fnamesearch." ".$lnamesearch."" returned <b>".$numrows."</b> results.</p>"; if ($numrows == 0) //if no matches, don't display the table exit; else //build the table and insert rows { echo "<table border=1 cellspacing=0 cellpadding=1 width='77%' align=left bordercolor=#666666>"; echo "<tr bgcolor=#cccc99 class='style5'><th width='10%' class='style5'>Date</th>"; echo "<th width='10%' class='style5'>Action</th>"; echo "<th width='12%' class='style5'>From</th>"; echo "<th width='12%' class='style5'>To</th>"; echo "<th width='5%' class='style5'>Pos</th>"; echo "<th width='18%' class='style5'>Name</th>"; echo "<th width='5%' class='style5'>Round</th></tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr><td width='10%' class='style6'>".$row['TRANS_DT']."</td>"; echo "<td width='10%' class='style6'>".$row['TRANS_ACTION']."</td>"; echo "<td width='12%' class='style6'>".$row['FROM_OWNER']."</td>"; echo "<td width='12%' class='style6'>".$row['TO_OWNER']."</td>"; echo "<td width='5%' class='style6'>".$row['POSITION']."</td>"; echo "<td width='18%' class='style6'>".$row['PLAYER_FNAME']." ".$row['PLAYER_LNAME']."</td>"; echo "<td width='5%' class='style6'>".$row['DRAFT_RND']."</td></tr>"; } /****** build the pagination links ******/ // if not on page 1, don't show back links if ($pageno > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'><<</a> "; // get previous page num $prevpage = $pageno - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'><</a> "; } // range of num links to show $range = 3; // loop to show links to range of pages around current page for ($x = ($pageno - $range); $x < (($pageno + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $lastpage)) { // if we're on current page... if ($x == $pageno) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$x'>$x</a> "; } // end else } // end if } // if not on last page, show forward and last page links if ($pageno != $lastpage) { // get next page $nextpage = $pageno + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>>></a> "; } // end if /****** end build pagination links ******/ echo "</table>"; } mysql_free_result($result); //release the result set from the table mysql_close($conn); //close the connection to the db ?> MOD EDIT: . . . tags added.
×
×
  • 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.