Web Hosting Talk







View Full Version : Some PHP Questions...


devanium
12-06-2004, 09:02 PM
Any help with this question would be greatly appreciated...

I am pulling data from a database (MySQL) using PHP, and displaying it as an HTML table. Here's what it looks like (http://chartsetups.com/user.php). The problem, as you can see, is that there are too many records on the page, forcing the user to scroll. Is there any way to fix this, while still showing all the data? Different form elements/combinations maybe?

Even a link to a tutorial or article - if you know of one - would be helpful, and greatly appreciated.

Thanks!

innova
12-06-2004, 11:39 PM
Pretty basic stuff :)

Why dont you just display the data differently?

Instead of cramming it all in one row, come up with your organization scheme and then have php fill in the blanks for you. You will probably not care to show all the data there anyway.. for example:

ID probably is an autoincrement field.. no sense in showing that most likely.

Before you begin, ask yourself what you want your end result to be. Only you know what you will WANT it to look like. Then, come ask how to do it.

null
12-07-2004, 12:12 AM
If user.php shows info for one user than you could display rows verticaly :)

devanium
12-07-2004, 03:50 AM
Thanks for the replies. The problem is, I can't think of many other ways to display the data. Here's what I came up with though:

http://chartsetups.com/images/ideal.jpg

Would it be possible to make the stock symbols links and have it output the data to a field below? The field below would be what null said - just displaying the rows vertically. But how do I display rows vertically, and how would I create a link that would react like that?

The problem with doing them all vertically would be the fact that there are - in practice - many more entries than just that, probably somewhere around 10-20 per week.

I guess I know the basics of PHP/MySQL, but finding a way to output to a different format (other than an HTML table as defined on php.net) is something I can't find much information on...

Any ideas?

Thanks!

devanium
12-10-2004, 08:51 PM
Anyone have any idea of what to do here?

Loon
12-10-2004, 09:32 PM
Bear in mind that your data is seperate from your HTML, so there's not really any limits to how you can display it on the page, as a paragraph, a list, a table anything you like.

You can also split the array of data you have using something like list() (see: www.php.net/list) so you could then display the output in sections, or seperate tables.

innova
12-10-2004, 10:08 PM
Oreilly's mysql cookbook has some fabulous examples of presenting this data in different ways.

Here is a thought:

Grab all the data from the DB as an array, then create an HTML template for your site. Populate the template using php's string functions like str_replace.

Good luck with your project!

sonic10
12-11-2004, 12:41 PM
You could just place the output to multiple tables...

<html>
<head><title>Page title</title></head>
<body>

<?php
$database="databasename";
mysql_connect ("localhost", "user", "passwd");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT Company_Name, Ticker_Symbol FROM dbtable" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>

<?php
$database="databasename";
mysql_connect ("localhost", "user", "passwd");
@mysql_select_db($database) or die( "Unable to select database");
$result = mysql_query( "SELECT Entry_Price, Exit_Price, Target_Price FROM dbtable" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
?>

</body>
</html>

devanium
12-11-2004, 09:07 PM
Thanks for the replies!