Monday, 19 August 2013

How to Pull Values from Data and Change Values on output

How to Pull Values from Data and Change Values on output

I am new to php and am learning on the fly. I used to do ColdFusion work a
long time ago and am rusty.
I am working with a database that I cannot modify that uses 3 letter codes
for locations such as WDC for Washington DC, ATX for Arlington, TX, and so
on.. I am trying to figure out how to get the results to show as the Full
Names instead of the short code. Here is the search results page code.. I
have tried to figure out using arrays and variables with no success. I am
not asking for full coding, but just to have someone point me in the right
direction or to get me started.. Also, if my code needs some work, any
pointers would be appreciated
$Search = $_GET['search'];
$Find_Query1 = mysql_query("select * from staff where (first like
'%$Search%' OR store like '%$Search%' OR phone like '%$Search%' OR dept
like '%$Search%' OR title like '%$Search%' OR store like '%$Search%' OR
last like '%$Search%') AND(inactive!='inactive') ORDER BY last" );
if(!$Find_Query1)
{
die(mysql_error());
}
if(mysql_num_rows($Find_Query1) > 0)
{
echo "<table width=\"700\" cellpadding=\"3\" align=\"center\">";
echo "<tr>";
for($i=0;$i<=mysql_num_rows($Find_Query1);$i=$i+1)
{ while($row = mysql_fetch_array($Find_Query1))
{$i++;
if($i%5==0)
{
echo "<td align=\"center\" > <img src=\"".$row["bigpic"]. "\"
width=\"140px\" border=\"1\"
/>"."<p><b>".$row["first"]."&nbsp;".$row["last"]."<br>"
.$row["title"]."</b><br>" .$row["store"]."</b><br>". "<a
href=mailto:".$row['email'] . ">" .$row['email'] . "</a><br>"
.$row["phone"]."</p></td></tr>"; } else { echo "<td
align=\"center\"><img src=\"".$row["bigpic"]. "\" border=\"1\"
width=\"140px\"/>"."<p><b>".$row["first"]."&nbsp;".$row["last"]."<br>".$row["title"]."</b><br>"
.$row["store"]."</b><br>" ."<a href=mailto:".$row['email'] . ">"
.$row['email'] . "</a><br>" .$row["phone"]."</td>"; }

No comments:

Post a Comment