PDA

View Full Version : Table & Field length adjustments


centris
08-23-2005, 04:43 PM
Is there a way to have a row that is about 20+ fields wrap around into 2 rows, then the next record do the same?

Or is it better to use 2 tables? I have a long form and would like to make it more readable. Also is there anyway to adjust the Field length besides what you specify as a value. I'm a bit new at MySQL and it seems there might be something I'm overlooking, or maybe it does not allow changing the columns & field length.

Thanks.

Kid Charming
08-23-2005, 06:50 PM
Display issues like wrapping tables with a lot of fields depend on what you're using to display your results. If you're on a GUI client or the command line, then you probably won't be able to. If you're displaying from a script, you can probably modify it.

Without knowing anything about your data, it's impossible to say whether you'd be better off with two tables, but don't let 'readability' make that decision. Read up on database normalization and do your best to make sure your tables fit into at least Third Normal Form.

Field lengths are set when your table is created and cannot be changed on a row-by-row basis. You can change them later with ALTER TABLE, but your changes will affect all rows in the table, so be careful.

centris
08-24-2005, 11:11 AM
Thanks for the information. I really didn't know about the different forms of normalization, and so I looked up what you said and it is interesting. My main concern as I am learning all of this and building the table - was for display purposes after a form was submitted and how to break that up, but I have somewhat of an idea using a PHP script and setting the display with that.

With the MySQL database I thought I might end up with more of a mess if I kept adding fields to one table. I don't have any duplicate data if I had more than 1 table, so that isn't a problem. I'm going to read more about this.

swatisonee
08-27-2005, 01:50 PM
I have an allied issue. I output data from a mysql table using php. All the field widths are ok when they appear on screen -barring one. That is a text field so then there's several sentences and it looks really odd on screen because that one column is overly long.
Is there anyway I can do a wordwrap for a single column ?

The script i use for display on screen is :

<table border="1" style="border-collapse: collapse" bordercolor="#111111" width="100%"><tr bgcolor="#D3D3D3">
<td><font size=2 face=Browallia New><b>Company</tr>
<td><font size=2 face=Browallia New><b>Date</tr>
<td><font size=2 face=Browallia New><b>Info</tr>
</tr>
(IN BETWEEN IS THE SQL QUERY THAT IS RUN)

if ($myrow = mysql_fetch_array($result))
{
do
{


printf("<tr>
<td><font face=\"Verdana\" size=\"2\"> %s </td>
<td><font face=\"Verdana\" size=\"2\"> %s </td>
<td><font face=\"Verdana\" size=\"2\"> %s </td>
</tr>",
$myrow["Company"],
calculatedate($myrow["Date"]),
$myrow["Info"]);

}
while ($myrow = mysql_fetch_array($result));
}
else
{
echo "Sorry, no records were found!";
}


Thanks for any and all advise.