Jump to content

petewall

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

petewall's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I actually solved it with for ($j = 1; $j <= 20; $j++) { if(!empty($row['j'.$j]) && is_numeric($row['k'.$j])) { echo $row['z'.$j]." "; echo $row['k'.$j]." "; echo $row['j'.$j]; echo "<br />"; } }
  2. 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?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.