Forum Moderators: coopster
i could use some help here as this is to difficult for me...below is a script that pulls info from the database.
it has 98 fields but this is showing all fields next to each other instead of below each other.
i want it like this:
word1
word2
word3
word4
but now it shows like:
word1 word2 word3 word4 etc..
So you can imagine 98 fields makes the page 10feet wide..
Who can help me to make the changes so it shows how i want?
im using database function,not file based.
Please...
<?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>";
}
echo "<td class=\"small\" align=\"center\" valign=\"middle\">Delete Record</td>";
echo "<td class=\"small\" align=\"center\" valign=\"middle\">Printer Friendly</td></tr>";
$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 "<td class='small'><center><a href='delete_file_rec.php?id=".$j."'>delete</a>";
echo "<td class='small'><center><a href=\"printer_friendly.php?id=" . $j . "\">Print</a></tr>";
}
echo "</table>";
} else if($db==1) {
// mySQL Table
$db_con = mysql_connect($hostname,$username, $password) 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>";
}
echo "<td class='small'><center>Delete Record</td>\n";
echo "<td class=\"small\" align=\"center\" valign=\"middle\">Printer Friendly</td></tr>\n";
$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 "<td class='small'><center><a href='delete_rec.php?id=".$j."'>delete</a></td>";
echo "<td class='small'><center><a href=\"printer_friendly.php?id=" . $j . "\">Print</a></tr>";
}
echo "</table>";
}
// mySQL ends
?>
<br /><br />
</TD></TR></TBODY> </TABLE></TD></TR> </TBODY></TABLE><BR></TD></TR>
<TR>
<TD class=small align=right></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>
[edited by: jatar_k at 8:09 pm (utc) on June 25, 2009]
[edit reason] fixed sidescroll [/edit]