kemper Posted December 12, 2006 Share Posted December 12, 2006 My page is displaying all content of the table, but I only want to display the fields from of table. Assistance is greatly appreciated. This is what I have thus far:<?php include("config.inc.php"); if ($db == 1) { echo "Using MySQL database info:<br><br>\n\n"; } elseif ($file_db == 1) { echo "Using file-based database:<br><br>\n"; } else { echo "Sorry. In order to use the administration portal you must use the MySQL or file-based database option.\n\n"; } if ($file_db == 1 && $db != 1) { $filedb = fopen("data.dat","r") or die ("<br>Could not open data file to read."); $columns_str = fgets($filedb,4096); $columns = explode("|",$columns_str); echo "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" width=\"90%\">\n"; echo "<tr><td colspan=\"" . (sizeof($columns)+2) . "\">\n"; echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n"; echo "<tr><td class=\"small\" bgcolor=\"#000000\" align=\"center\" valign=\"middle\">\n"; echo "<font color=\"#ffffff\">Records Table</td></tr></table></td></tr><tr>\n"; for ($i=0;$i<sizeof($columns);$i++) { echo "<td class=\"small\" align=\"center\" valign=\"middle\"><b>".$columns[$i]."</b></td>"; } $i=0; while (!feof($filedb)) { $temp = fgets($filedb,4096); if ($temp != "") { $records[$i]=$temp; $i++; } } for($j=0;$j<$i;$j++) { echo "<tr>"; $holder = explode("|",$records[$j]); for ($k=0;$k<sizeof($holder);$k++) { echo "<td class='small'><center>$holder[$k]</td>"; } } echo "</table>"; } else if($db==1) { // mySQL Table $db_con = mysql_connect("MyHost", "MyUser", "MyPassword") or die("Connetion to database failed!"); mysql_select_db($dbname); $query = "select * from ".$table; $result = mysql_query($query); $i = 0; while ($i < mysql_num_fields($result)) { $meta = mysql_fetch_field($result); $columns[$i] = $meta->name; $i++; } echo "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" width=\"90%\">\n"; echo "<tr><td colspan=\"" . (sizeof($columns)+2) . "\">\n"; echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n"; echo "<tr><td class=\"small\" bgcolor=\"#000000\" align=\"center\" valign=\"middle\">\n"; echo "<font color=\"#ffffff\">Records Table</td></tr></table></td></tr><tr>\n"; for($i=1;$i<sizeof($columns);$i++) { echo "<td class='small'><center><b>".$columns[$i]."</td>"; } $query = "select * from ".$table; $result = mysql_query($query); $j=0; while($row=mysql_fetch_array($result)) { echo "<tr>"; for($i=1;$i<sizeof($columns);$i++) { echo "<td class='small'><center>".$row[$columns[$i]]."</td>"; } $j=$row[$columns[0]]; } echo "</table>"; } // mySQL ends?><br /><br /></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR></TD></TR><TR><TD class=small align=right>© 2006-2007</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></center></form></body></html> Quote Link to comment Share on other sites More sharing options...
john010117 Posted December 12, 2006 Share Posted December 12, 2006 Please use the code tags so we can read it better. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.