homepage Welcome to WebmasterWorld Guest from 54.197.65.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
displaying info below each other instead of next to each other
john1000

5+ Year Member



 
Msg#: 3939921 posted 11:40 pm on Jun 24, 2009 (gmt 0)

hello,

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]

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3939921 posted 8:11 pm on Jun 25, 2009 (gmt 0)

which specific line or lines of code are you wanting to change?

john1000

5+ Year Member



 
Msg#: 3939921 posted 8:31 pm on Jun 25, 2009 (gmt 0)

thanks....
but i decided to look for another solution...
im looking for a form that can submit info to a table and can populate it as the form has 98 fields..
but it also must show the results on a page as well.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved