WebsiteBaker 2.13.9 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
$fields_array=array(); $num_fields=0; $num_row=0;// Define Table Used Here// Can be used for multiple tables, but must define here or hard code in SQL search $table="wb1_users";// SQL select for table// Current example displays all headings for an individual table $sql = "SELECT * FROM `$table`"; // find position of "FROM" in query $fpos=strpos($sql, 'from');// get string starting from the first word after "FROM" $strfrom=substr($sql, $fpos+5, 50);// Find position of the first space after the first word in the string $Opos=strpos($strfrom,' ');// Get result from query $result=mysql_query($sql); $num_row=mysql_numrows($result); if($num_row >0) {//Get number of fields in query $num_fields=mysql_num_fields($result); // get column metadata $i = 0; echo ('<br>'); echo('<br><table border="1" color="black" align="center" ><thead><tr>'); while ($i < $num_fields) {//Get fields (columns) names $meta = mysql_fetch_field($result); $fields_array[]=$meta->name;// Can Display Headers in UPPER, LOWER, OR PROPER CASE// example db table heading is: MyTableHeading// code Output// strtoupper for upper case MYTABLEHEADING// strtolower for lower mytableheading// ucfirst for for first letter upper Mytableheading// if no code is used headign will be as in table MyTableHeading// Example Codes// upper case example print('<th><b>'.strtoupper($fields_array[$i]).'</b></th>');// no ftn example print('<th><b>'.$fields_array[$i].'</b></th>'); echo ('<th SCOPE="col"><b>'.$fields_array[$i].'</b></th>'); $i=$i+1; } echo ('</tr></thead>'); echo ('<tbody>'); //Get values for each row and column while($row=mysql_fetch_row($result)) { echo ('<tr>'); for($i=0; $i<$num_fields; $i++) {//Display values for each row and column echo ('<td>'.$row[$i].'</td>'); } echo ('</tr>'); } } echo ('</tbody>'); echo ('</table>'); echo ('<br>');
DisplayTable
[[DisplayTable?table=wb1_users]]
Display contents of a table [[DisplayTable?table=wb1_users]]
$fields_array=array(); $num_fields=0; $num_row=1; // Define Table Used Here// Can be used for multiple tables, but must define here or hard code in SQL search// $table="wb1_users";// SQL select for table// Current example displays all headings for an individual table $sql = "SELECT * FROM `$table`"; // find position of "FROM" in query $fpos=strpos($sql, 'from');// get string starting from the first word after "FROM" $strfrom=substr($sql, $fpos+5, 50);// Find position of the first space after the first word in the string $Opos=strpos($strfrom,' ');// Get result from query $result=mysql_query($sql); $num_row=mysql_numrows($result); // get string starting from the first word after "FROM" $strfrom=substr($sql, $fpos+5, 50); // Find position of the first space after the first word in the string $Opos=strpos($strfrom,' ');// Get result from query $result=mysql_query($sql); $num_row=mysql_numrows($result); if($num_row >0) {//Get number of fields in query $num_fields=mysql_num_fields($result); // get column metadata $i = 0; $output .= '<br>'."\n"; $output .= '<br><table id="myDynamicTable"><thead><tr>'."\n"; while ($i < $num_fields) {//Get fields (columns) names $meta = mysql_fetch_field($result); $fields_array[]=$meta->name;// Can Display Headers in UPPER, LOWER, OR PROPER CASE// example db table heading is: MyTableHeading// code Output// strtoupper for upper case MYTABLEHEADING// strtolower for lower mytableheading// ucfirst for for first letter upper Mytableheading// if no code is used headign will be as in table MyTableHeading $output .= '<th SCOPE="col"><b>'.$fields_array[$i].'</b></th>'."\n"; $i=$i+1; }$output .= '</tr></thead>'."\n"; $output .= ' <tbody> '."\n"; //Get values for each row and column while($row=mysql_fetch_row($result)) {$output .= '<tr> '."\n"; for($i=0; $i<$num_fields; $i++) {//Display values for each row and column$output .= ' <td>'.$row[$i].' </td> '."\n";}$output .= '</tr> '."\n";} }$output .= '</tbody></table> '."\n";return $output;