Reputation: 15
So guys hello, So The code is matching already with the database i want to do a logic that,... level=from the database matches to the array dischargelabel, AND the problem is iwant to next the on the array that match on the database example: if level=inpatient dischargelabel=inpatient, MATCH THEN POST the next array which is inpatient11 on the array named dischargelabel
<?php
$result1 = mysql_query("SELECT * FROM dailymed WHERE fname='$fname' and ipn='$ipn'");
while ($row = mysql_fetch_array($result1)) {
$level33 = $row['level'];
}
$dischargelabel = array(
dexample,
discharge,
discharge1,
discharge2,
inpatient,
inpatient11
);
if (in_array($level33, $dischargelabel)) {
$dies = $arrput = $dischargelabel;
echo next($dies);
ECHO "MATCH FOUND";
} else {
echo "Match not found";
}
?>
Thankyou Guys for helping me.
Upvotes: 1
Views: 59
Reputation: 1700
Try using array_search()
, hope below code helps you:
$dischargelabel = array('dexample','discharge','discharge1','discharge2','inpatient','inpatient11');
$key = array_search($level33, $dischargelabel);
if (false !== $key)
{
echo (isset($dischargelabel[$key+1]))?$dischargelabel[$key+1]:'';
ECHO "MATCH FOUND";
}
else
{
//ELSE PLUS discharge+1
echo "Match not found";
}
Upvotes: 1