PHP query MySQL database, and the results columns display, the following code:
- <?php
- Session_Start ();
- Include ("conn.php");?>
- <title> Query Results columns Display-www.cxybl.com</title>
- <body>
- <table width= "450" border= "1" align= "center" cellpadding= "0" cellspacing= "0" >
- <?php for ($i =1 $i <=4; $i + +) {//if variable <=4, loop by row, output line
- echo "<tr>"; ?>
- <?php if ($i ==1) {
- $query = "SELECT * from Tb_picture where ID order by id DESC"; Get emoticons from datasheet MR_LTTB
- $LTTB =mysql_query ($query); }
- $j = 1; Set Variable $j=1
- while ($LTTB _row=mysql_fetch_array ($LTTB)) {//For While loop output
- if ($j <=6) {//<=8 the number of emoticons per row, output the following
- if ($c ==0) {$c = "checked";}
- ?>
- <TD height= "align=" center "valign=" Middle ">
- <input name= "XQ" type= "Radio" value= "<?php echo $LTTB _row[id];? > "<?php echo $c;? >>
- "width=" height= "></td>"
- <?php}
- $c = 1;
- + + $j; As the number of emoticons increases,
- if ($j ==7) {break; //When the number of emoticons equals 9 o'clock, jump to the next line to cycle again
- }
- echo "</tr>";
- }
- ?>
- </table>
- </body>
conn.php:
- <?php
- $id =mysql_connect ("localhost", "root", "MySQL") or Die (' Connection failed: '. mysql_error ());
- if (mysql_select_db ("phpjcdb", $id))//Description: PHPJCDB is the database name
- echo "";
- Else
- Echo (' Database selection failed: '. mysql_error ());
- mysql_query ("Set names gb2312"); Set to Simplified Chinese
- ?>