-2

How can i minimalize that PHP code? Or write it in an easier way?

    $res = mysqli_query($mysqlc, "SELECT id FROM admin_szallas") or die(mysqli_error($mysqlc));
while($row = mysqli_fetch_array($res)) {

    $szID = $row["id"];
    mysqli_query($mysqlc, "INSERT INTO admin_ertesitesek (szallasID, ido, uzenet, allapot, akcio) VALUES('$szID', '$ido', '$cim', '0', '$akcio')") or die(mysqli_error($mysqlc));  

}

1 Answers1

0

People can see in here different problems.

  1. Coding style of presented code.
  2. Usage of procedural functions instead of object-oriented.
  3. Usage of die() instead of Exceptions.

If you want to protect it from SQL Injection check out this topic.

Community
  • 1
  • 1
nass
  • 382
  • 1
  • 6
  • 19