php - insert an array into table using for loop -
I am trying to insert the rows of data into an array in the table in the mysql database. I am starting php, mysql and there is very little information about it. I just want to learn more if you can try it it would be great.
The code I want to insert is below:
for ($ x = 0; $ x & lt; 2; $ X ++) {$ Data [$ x] ['title'] = $ title- & gt; Items ($ x) - & gt; Nodeville; $ Data [$ x] ['titleHrefQuery'] = $ headerHrefQuery-> Items ($ x) - & gt; Nodeville; $ Data [$ x] ['food'] = $ FOODGRAIN- & gt; Object ($ x) - & gt; Nodeville; $ Data [$ x] ['locality'] = $ locality-> object ($ x) - & gt; Nodeville; $ Data [$ x] ['rating'] = $ rating-> object ($ x) - & gt; Nodeville; $ Data [$ x] ['cost'] = $ costQuery- & gt; Items ($ x) - & gt; Node valve; } I am tring to insert using the code given below:
$ query = "Include in the table (` title`, `Link`,` value ($ ') - & gt; item ($ x) - & gt; node vela.' ',' ". $ TitleHrefQuery- & gt; item ($ x)) - gt; nodeValue. ' '$' -> $ Food-> Object ($ x) - & gt; nodeValue. '', ''. $ Locality-> Object ($ x) - & gt; Nodeville., ''. $ Rating- Gt; & gt; Items ($ x) - & gt; nodevalue. '', ''. $ CostQuery- item ($ x) - & gt; nodeville. '' '); "; $ Result = mysql_query ($ query); If ($ result) {echo ("success"); } Else {echo ("not added"); } But every time it does not show the pair. Please help !!
Change
Insert in the table Because the table is a reserved keyword. And if you are using reserved keywords Name the name of the table or name of the column, then you must include them in the back-tie (`). Apart from this, no reserved keywords should be used. If you can change the name then it will be the best option. You can check more of these questions
-
-
-
Comments
Post a Comment