if statement - PHP If Else Error -
I am trying to fill the table with the data from the database using mysqli and php. Using the following code:
& lt ;? Php if (mysqli_num_rows ($ search_query) & gt; {) {to {& lt; Tr & gt; & Lt; TD & gt; Resonate $ rows ['COL 1']; & Lt; / TD & gt; & Lt; TD & gt; Resonate $ rows ['COL 2']; & Lt; / TD & gt; & Lt; TD & gt; Echo $ rows ['COL 3']; & Lt; / TD & gt; & Lt; TD & gt; $ Rows ['col 4']; & Lt; / TD & gt; & Lt; TD & gt; Resonate $ rows ['col 5']; & Lt; / TD & gt; & Lt; TD & gt; $ Rows ['col 6']; & Lt; / TD & gt; & Lt; TD & gt; Repeat $ rows ['COL 7']; & Lt; / TD & gt; & Lt; TD & gt; $ Rows ['col 8']; & Lt; / TD & gt; & Lt; TD & gt; Resonate $ rows ['col 9']; & Lt; / TD & gt; & Lt; TD & gt; $ Lines ['COL 10'] resonate; & Lt; / TD & gt; & Lt; TD & gt; Echo ['COL 11']; & Lt; / TD & gt; & Lt; TD & gt; $ Rows ['col 12']; & Lt; / TD & gt; & Lt; TD & gt; $ Rows ['col 13']; & Lt; / TD & gt; & Lt; / TR & gt; } While ($ line = mysqli_fetch_assoc ($ search_query)); } Else {echo "No results found."; }? & Gt;
I get an error and do not see anything on the website. I'm sure it has to do with php tags but I do not know how to use them properly I have also tried:
0) {{{? & Gt; & Lt; TR & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 1'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col2'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 3'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 4'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 5'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo per line ['col 6'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 7'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 8'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['9 9]';; & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php resonance ['COL 10'];? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 11'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 12'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 13'] ;? & Gt; & Lt; / TD & gt; & Lt; / TR & gt; } & Lt ?? Php while ($ rows = mysqli_fetch_assoc ($ search_query)) ;? & Gt; & Lt; / Table & gt; } & Lt ;? Php else {echo "No results found."; }? & Gt;
While simply loop, try one normally.
A do while executing the first part, $ rows will be undefined.
& lt ;? Php if (mysqli_num_rows ($ search_query)> 0) {? & Gt; & Lt; Table & gt; & Lt ;? Php while ($ rows = mysqli_fetch_assoc ($ search_query)) {? & Gt; & Lt; TR & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 1'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col2'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 3'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 4'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 5'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo per line ['col 6'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 7'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 8'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['9 9]'? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php resonance ['COL 10'];? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 11'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php ek $ rows ['col 12'] ;? & Gt; & Lt; / TD & gt; & Lt; Td> & Lt ;? Php echo $ rows ['col 13'] ;? & Gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; / Table & gt; & Lt ;? Php} else {echo "No results found."; }? & Gt;
In your second example, you also have a closing bracket outside of your PHP tag. Turning on error reporting will give you an informational error message.
error_reporting (E_ALL); Ini_set ('display_errors', 'on');
Comments
Post a Comment