Page 1 of 1

Just after a filter function I think

Posted: Tue Apr 20, 2004 5:19 am
by ]{ronic
Hey ..

How can I make the below script display only the records that match "air division" in the "division" column of members mysql table..

Code: Select all

<?php
$dbname="####";
$dbtable="####";
$hostserver="####";
$username="####";
$password="####";

$db = @mysql_connect("$hostserver","$username","$password")
or die ("Problems connecting to database server"); 

@mysql_select_db ("$dbname") or die ("Problem selecting database");
$sql = "SELECT * FROM $dbtable";

$result = mysql_query($sql); 
while ($row = mysql_fetch_array($result)) {
$alias = $row["alias"]; 
$datejoined = $row["datejoined"]; 
$rank = $row["rank"]; 
$division = $row["division"]; 
$prefclass = $row["prefclass"]; 
$prefvehicle = $row["prefvehicle"]; 
$speciality = $row["specialty"]; 
$avatar = $row["avatar"];
?>
<table width="90%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolor="#413723">
<tr> 
<td height="20" colspan="2" valign="middle"><div align="center"><font class=two>Urban Legends Forces Member</font></div></td>
<td width="45%" height="20"><font>Date Joined:</font> <?php echo $row['datejoined']; ?></td>
</tr><tr> 
<td width="14%" rowspan="4"><div align="center"><img src="<?php echo $row['avatar']; ?>"></div></td>
<td width="41%" height="20"><font>Alias:</font> <?php echo $row['alias']; ?></td>
<td height="20"><font>Rank:</font> <?php echo $row['rank']; ?></td>
</tr><tr> 
<td height="20"><font>Wolf Pack</font></td>
<td height="20"><font>Division:</font> <?php echo $row['division']; ?></td>
</tr><tr> 
<td height="20"><font>Pref Class:</font> <?php echo $row['prefclass']; ?></td>
<td height="20"><font>Pref Vehicle:</font> <?php echo $row['prefvehicle']; ?></td>
</tr><tr> 
<td height="20" colspan="2"><font>Specialty:</font> <?php echo $row['specialty']; ?></td>
</tr></table>
<div align="left"><br>
<?php
}
?>

]{ronic

Posted: Tue Apr 20, 2004 5:50 am
by JayBird
just change your query to

Code: Select all

SELECT * FROM $dbtable WHERE division ='air division'
Mark

Posted: Tue Apr 20, 2004 7:57 am
by ]{ronic
works .. thanks dude ..


]{ronic

Posted: Tue Apr 20, 2004 7:39 pm
by ]{ronic
Hey

With the above code .. how can I display the number of members in a division or total members within that page or any other page in my site?


Thanks

]{ronic

Posted: Tue Apr 20, 2004 7:47 pm
by magicrobotmonkey
SELECT count(*) FROM $dbtable WHERE division = $divName