I’ve put some code up at http://brewhas.org/transactions.php and could use some help.
Basically, I’m allowing the user to input the fname and lname of a player, and retrieving the transactions that match the player’s name and formatting those rows into an HTML table. That’s working, but the table appears to be pushed down a certain distance, and the distance appears to be related to the number of rows.
Say if you type in last name of ‘pujols’, the 10 rows are pushed down but still on the screen. Enter in a last name of ‘will’ and there are a lot more rows (using LIKE) so it’s really pushed down.
Also, I tried to add validation on the last name needing to be populated but when I hit that validation, I still get a large number of rows being returned (possibly due to the LIKE?).
Can anyone help sort this out? thanks
[php]<?php
include ‘config.php’;
include ‘opendb.php’;
$fnamesearch = $_POST["fnamesearch"];
$lnamesearch = $_POST["lnamesearch"];
$fnamesearch=strtoupper($fnamesearch);
$lnamesearch=strtoupper($lnamesearch);
if ($_POST["lnamesearch"]== ""){
echo "Please enter the last name.";
}
if ($_POST["fnamesearch"]== ""){
$query = "SELECT * from BKL_TRANSACTIONS WHERE PLAYER_LNAME LIKE '$lnamesearch%'";
}
else {
$query = "SELECT * from BKL_TRANSACTIONS WHERE((PLAYER_LNAME LIKE '$lnamesearch%')& (PLAYER_FNAME LIKE '$fnamesearch%'))";
}
$result = mysql_query($query);
if (!$result)
{
die ("Could not query the database: <br />". mysql_error());
}
echo "<table border=1 cellspacing=0 cellpadding=1 width='77%' align=center 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>";
echo "<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>";
echo "<br/>";
}
echo "</table>";
mysql_close($conn);
?>[/php]