Hello, I'm rather new here. I hope this is posted in the right group.
I'm making a database of Dutch wind mills. Those mills contain parts
that give, after clicking, more details. E.g. you can get more
information either about the standing construction or the moving
construction. Now a problem is that I have a lot of fields, but a
query usually gives just a few rows, at most five. So a better
presentation is by turing the rows into columns.
My earlier presentation can be seen from the following code:
<?php
........
$result = (mysql_query($sql, $conn) or die(mysql_error());
echo "<table border = 1>";
echo "<tr alignment = center>";
for($i=0; $i<mysql_num_rows; $i++)
{
echo "<th>".mysql_field_name($result, $i)."</th>";
}
echo "</tr>";
while ($row=mysql_fetch_row($result))
{
echo "<tr align=left>";
for ($i=0; $i<mysql_num_rows(result);$i++)
{
echo "<td>";
if(!isset($row[$i])) //test for NULL
{echo ".";}
else
{echo $row[$i];}
echo "</td>";
}
}
echo "</table>";
?>
I thought it best to make a twodimensional array of the result of my
query. I did it like this.
<?php
$result = (mysql_query($sql, $conn) or die(mysql_error());
settype ($movpart, "array");
for($i=0; $i<mysql_num_rows($result);$i++)
{
for ($j=0; $j<mysql_num_fields($result);$j++)
{
$movpart[$i][mysql_field_name($result,$j)]=
mysql_result($result,$i,mysql_field_name($result,$ j));
}
}
settype ($veld, "array");
for ($v=0; $v<mysql_num_fields($result);$v++)
{
$veld[$v]= mysql_field_name($result,$v);
}
echo "<table>";
for ($v=0; $v<mysql_num_field($result); $v++)
{
echo"<tr alignment=center>";
echo"<th>";
echo $veld[$v];
echo "</th>";
}
echo "</table>";
echo "<table>";
for($k=0; $k<mysql_num_field($result); $k++)
{
echo "<tr align=left>";
for($l=0; $l<mysql_num_rows($result); $l++)
{
echo"<td>";
echo $movpart[$l][$veld[$k]];
echo"</td>";
}
echo"</tr>";
}
echo"</table>";
?>
By placing the last two tables each in a cell of a two-cell table I
get my results. Although the presentation is more or less what I
wanted, it is not very elegant. Has anyone suggestions to a better
solution?
Tanks in advance,
Koos 1 1378
Koos de Vries wrote:
Hello, I'm rather new here. I hope this is posted in the right group.
I'm making a database of Dutch wind mills. Those mills contain parts
that give, after clicking, more details. E.g. you can get more
information either about the standing construction or the moving
construction. Now a problem is that I have a lot of fields, but a
query usually gives just a few rows, at most five. So a better
presentation is by turing the rows into columns.
My earlier presentation can be seen from the following code:
<?php
.......
$result = (mysql_query($sql, $conn) or die(mysql_error());
echo "<table border = 1>";
echo "<tr alignment = center>";
for($i=0; $i<mysql_num_rows; $i++)
{
echo "<th>".mysql_field_name($result, $i)."</th>";
}
echo "</tr>";
while ($row=mysql_fetch_row($result))
{
echo "<tr align=left>";
for ($i=0; $i<mysql_num_rows(result);$i++)
{
echo "<td>";
if(!isset($row[$i])) //test for NULL
{echo ".";}
else
{echo $row[$i];}
echo "</td>";
}
}
echo "</table>";
?>
I thought it best to make a twodimensional array of the result of my
query. I did it like this.
<?php
$result = (mysql_query($sql, $conn) or die(mysql_error());
settype ($movpart, "array");
for($i=0; $i<mysql_num_rows($result);$i++)
{
for ($j=0; $j<mysql_num_fields($result);$j++)
{
$movpart[$i][mysql_field_name($result,$j)]=
mysql_result($result,$i,mysql_field_name($result,$ j));
}
}
settype ($veld, "array");
for ($v=0; $v<mysql_num_fields($result);$v++)
{
$veld[$v]= mysql_field_name($result,$v);
}
echo "<table>";
for ($v=0; $v<mysql_num_field($result); $v++)
{
echo"<tr alignment=center>";
echo"<th>";
echo $veld[$v];
echo "</th>";
}
echo "</table>";
echo "<table>";
for($k=0; $k<mysql_num_field($result); $k++)
{
echo "<tr align=left>";
for($l=0; $l<mysql_num_rows($result); $l++)
{
echo"<td>";
echo $movpart[$l][$veld[$k]];
echo"</td>";
}
echo"</tr>";
}
echo"</table>";
?>
By placing the last two tables each in a cell of a two-cell table I
get my results. Although the presentation is more or less what I
wanted, it is not very elegant. Has anyone suggestions to a better
solution?
Tanks in advance,
Koos
Please don't multipost. Crosspost instead.
Response in alt.php.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Don Leverton |
last post by:
Hi Folks,
I have been given a CD with approx 130 .xls files (bean-counters!) that I
would like to import and merge to ONE table (tblTradeshow).
The XL files are *similarly*, but not...
|
by: Ralph |
last post by:
I'm trying to import a range of cells from an Excel spreadsheet into a
table in access. The first row contains column labels, but I cannot
use those as my field names, both because of their format...
|
by: Geoff Portbury |
last post by:
I'm a swimming club coach.
I have a data base for recording times at various meets.
I have a FORM for entering times called SWIM TIMES.
When I enter the swimmers name ID, eg FOR01 for Doug Ford I...
|
by: bitoulis |
last post by:
Hi,
is it possible to use the records of a table as the field names of
another table?
If yes, how is it done?
Thanks in advance
Laertes
|
by: Bob |
last post by:
When displaying data from the database, very often the field names are not
suitable so custom headings have to be created, For example, the column
storing zip code may be named zip, but when...
|
by: dhnriverside |
last post by:
Hi guys
Ok, here's the situation. I'm building a reporting system for my
application, that basically creates a CSV file based on a load of data in my
database.
I'm trying to make the...
|
by: jerry.ranch |
last post by:
I'm building my own crosstab table.
If a crosstab field has no data in the entire field (as a result of
filtering), I don't want to show that field. Is there a way to do
this in a qry or frm...
|
by: windandwaves |
last post by:
Hi Folk
I have to store up to eight boolean bits of information about an item
in my database.
e.g.
with restaurant
drive-through facility
yellow windows
|
by: Bob |
last post by:
Hi all,
I've got a table that I've imported and it has junk at the top of the
table, so after import I run a delete query to remove the junk lines
then I'm left with the field names I want for...
|
by: Andy B |
last post by:
If I have the following text in a dataset table column: "This agreement
establishes that {BandName} will play on {EventDate} between {StartTime} and
{EndTime}..." How would I then take the field...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |