I am using the following array below and it works fine. However I would like it to only show the ore that is greater than 0.
and it displays like this
So I'd like it to only show the Copperdust and Lavarock since they are greater than 0 for this item.
My second question is how do I update only the values affected? My database is normalized and this is a standard update query for it.
Thanks
PHP Code:
$furnquery = doquery("SELECT * FROM {{table}} WHERE name='$name'", 'furnace');
if (mysql_num_rows($furnquery) == 0) {
display("<p>There is no equipment by this name.<br /><br />You may now return to the <a href=\"furnace.php\">Furnace</a>.", "Error");
}
$frow = mysql_fetch_array($furnquery);
$arr = array('Copperdust' => $frow['ore1'],
'Lavarock' => $frow['ore2'],
'Turquoise' => $frow['ore3'],
'Fire Opal' =>$frow['ore4'],
'Meteorite' => $frow['ore5'],
'Angels' => $frow['ore6'],
'Diamond' => $frow['ore7']);
foreach ($arr as $key => $frow) {
$page .= "You gained $frow $key<br />";
}
PHP Code:
You gained 12 Copperdust
You gained 3 Lavarock
You gained 0 Turquoise
You gained 0 Fire Opal
You gained 0 Meteorite
You gained 0 Angels
You gained 0 Diamond
My second question is how do I update only the values affected? My database is normalized and this is a standard update query for it.
PHP Code:
if (mysql_num_rows($ore1query) == 1) {
$updatequery = doquery("UPDATE {{table}} SET amount=amount+$orecount WHERE playerid='".$userrow['id']."' AND itemid='16' LIMIT 1", "useitems");
}
else {
$query = doquery("INSERT INTO {{table}} SET id='', playerid='".$userrow['id']."', itemtype='3', amount='$orecount', itemid='16', itemname='Copperdust'", "useitems");
}
Comment