im not a pro on this but why doesnt this work? $SQL = "REPLACE INTO Levels SET id = '$id' AND levelname = '$levelname', walls = '$walls' AND floors = '$floors';";
If you're trying to replace data in an existing row, you need to use UPDATE. So your code would become $SQL = "UPDATE Levels SET id = '$id' AND levelname = '$levelname', walls = '$walls' AND floors = '$floors';"; But you need to be careful here because there is no WHERE clause so the update would change every row in the table. You use INTO with an INSERT command.
well i want it to check if it already exists, and if it doesnt then it will create a row, and if it does it will replace the data? am i taking the right approach?
No. Select the row. If you get one, update it. If you don't, insert one. There's no "replace if it exists, otherwise create one" SQL syntax.
There is Replace in MySQL. Refer it here. You can also try INSERT INTO .. ON DUPLICATE KEY UPDATE. refer this.
I did an select all, then if any rows will update, else will insert. is doing replace necessarily "better" when it comes to bandwith and such
Website bandwidth has nothing to do with mysql query as long as data retrieved by mysql is not transferred at client end. Queries run solely on server, mostly same server on shared host. If you have 2 separate server for front-end and back-end, and doing single select and insert, then of course network usage can happen, however that again is not the end-user bandwidth utilization.