Saturday 15 September 2012

arrays - Check the table row and column number with database give row id and column id in PHP -


In my project I have used 10 * 10 tables for two ends. There are two fields for row_id and column_id in my database. I want to check whether the given line id and column id table given the database is similar to the row number and column number, print some strings. But check the first database value only in the following code. What's the problem with the code given below?

  print ('& lt; table range = "1" cellpaction = "0" cellpadding = "2" & gt;'); For {$ X = 1; $ x ; ($ Line = mysqli_fetch_array ($ result)) {If ($ line ['row_id'] == $ x & amp; $ row ['column_id'] == $ y) Print ($ line ['img_title']) ; The second "no IMG" is not echo; } Echo $ x $ Y; Echo "& lt; / td>"; } Resonates "& lt; / tr & gt;"; } Print ('& lt; / table & gt;');  
  while ($ line = mysqli_fetch_array ($ result)) {// ....}   

Because this code will get all the rows at once (in your case, your first column and first line) and you can not reuse it on the second column and row You can get all the rows and can store them in a temporary array. For example <$> [$ row = mysqli_fetch_array ($ result)) {$ temp [$ row ['row_id']] [$ line ['column_id'] for example

]] = True; }

then in your nested loop:

 for  ($ x = 1; $ x    

No comments:

Post a Comment