Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsteve choi
Courses Plus Student 1,199 Points"" and '' for PHP
Hello,
I am having trouble clearing up below command. The goal that I am trying to achieve is to run loop php command to insert multiple logs into the SQL database at once.
I am guessing below "" and '' is not cleared up and is not working. ** the last two variables being inputted into the database is dynamic array and want to apply loop to those variable names as well. "${'array' . $x}[0]", "${'aray' . $x}[1]")";
Is there any way to clean this up? Below is the code that i am working with.
Any support is greatly appreciated!
for ($x = 0; $x <= $Lkey; $x++) { ${'sql' . $x}="INSERT INTO table (column1,column2,column3,column4,column5) VALUES ('$variable1','$variable2','$variable3', "${'array' . $x}[0]", "${'aray' . $x}[1]")";
${'res' . $x=mysqli_query($connector,${'sql' . $x});