Hi,
I use a query which is identical throughtout my application, only thing that differs is the select part of the query,
so for example:
mysql_select_db("mydatabase", $con);
$result4 = mysql_query("SELECT * FROM nap where Exchange LIKE '$majorvalue%'");
while($row = mysql_fetch_array($result4))
{
$psba = $row['Site'];
$status = $row['Status'];
$spectrum = $row['InSpectrum'];
$exchange = $row['Exchange'];
$exchange = str_replace("_"," ",$exchange);
$street = $row['Street'];
$city = $row['City'];
$county = $row['County'];
$zip = $row['Zip_Postal_Code'];
$circuit = $row['Circuit Details'];
$groupname = $row['Site_Group'];
// LETS GET RID OF UNDERSCORES AND SPACES ETC..
$expr = '/(?<=\s|^)[a-z]/i';
preg_match_all($expr, $groupname, $matches);
$newresult = implode('', $matches[0]);
$newresult = strtoupper($newresult);
/* echo statements here*/
}
The only bit that ever will change is the select statements, so I wanted to put the repeat code as a function and call it after the select statement so it would read:
mysql_select_db("mydatabase", $con);
$result4 = mysql_query("SELECT * FROM nap where Exchange LIKE '$majorvalue%'");
while($row = mysql_fetch_array($result4))
{
myfunction();
}
I just cant seem to get it too work?