hey, i have a little problem, i'm fetching data from a table with 20x3 columns. i've namned them
j1 -> j20,
k1 -> k20,
z1 -> z20.
i need to check wether j1 -> j20 is empty and that k1 -> k20 is numeric.
and if both these criteria are not met, none of j, k or z should be outputted.
i've tried with
if(!empty($row['j1']) && is_numeric($row['k1'])) {
echo $row['z1']." ";
echo $row['k1']." ";
echo $row['j1'];
echo "<br />";
}
if(!empty($row['j2']) && is_numeric($row['k2'])) {
echo $row['z2']." ";
echo $row['k2']." ";
echo $row['j2'];
echo "<br />";
}
it works, but theres just ALOT of code for something small and i'm wondering if there's another way to do this, maybe with a for-loop or something?
i tried with:
for ($j = 1; $j <= 20; $j++) {
if(!empty($row['j1$j'])) {
echo $row['z$j']." ";
echo $row['k$j']." ";
echo $row['j$j'];
echo "<br />";
}
}
But i'm guessing you can't have the $j inside the $row[''].
Anyone got any ideas? on how to make this piece of code more simple?