473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Problem with table...

I wrote a php script that reads some dara from database and displays it as
a table:
The problem is that the data are showing in table rows Is it possible to
display it as a new colum next to an existing one?
Here is php code::
echo "<table align=\"center\" width=\"100%\">";
echo"<tr><td>Room:</td></tr>";
echo"<tr><td>Price:</td></tr>";
echo"<tr><td>How many rooms?:</td></tr>";

// data display

$wynik2=mysql_query($hotel_query2);
while($wiersz2=mysql_fetch_array($wynik2,MYSQL_NUM ))
{
echo"<tr><td>".return_data($wiersz2[0])."</td></tr>";
echo"<tr><td >".return_data($wiersz2[1])."</td></tr>";
echo"<tr><td >".return_data($wiersz2[2])."</td></tr>";
}
echo "</table>";

Each while pass creates 3 rows. Is it possible to make new column (with 3
rows) next to the one that already exists?

Thanks.
Leszek
Jan 6 '06 #1
11 1199
Leszek wrote:
I wrote a php script that reads some dara from database and displays it as
a table:
The problem is that the data are showing in table rows Is it possible to
display it as a new colum next to an existing one?

Here is php code::
Let me edit your code. I'll remove several <tr> and </tr>:

echo "<table align=\"center\" width=\"100%\">";
echo"<tr><td>Room:</td>";
echo"<td>Price:</td>";
echo"<td>How many rooms?:</td></tr>";

// data display

$wynik2=mysql_query($hotel_query2);
while($wiersz2=mysql_fetch_array($wynik2,MYSQL_NUM ))
{
echo"<tr><td>".return_data($wiersz2[0])."</td>";
echo"<td >".return_data($wiersz2[1])."</td>";
echo"<td >".return_data($wiersz2[2])."</td></tr>";
}
echo "</table>";
Each while pass creates 3 rows. Is it possible to make new column (with 3
rows) next to the one that already exists?


Is this what you mean? <tr> starts a new row; you do not want to put
each "column" in its own row.

--
-bts
-Warning: I brake for lawn deer
Jan 6 '06 #2
I want to get this:

//Column1 Column2
Room: return_data($wiersz2[0])
Price: return_data($wiersz2[1])
How many?: return_data($wiersz2[2])

But using my code i'm getting:

Room:
Price:
How many?:
return_data($wiersz2[0])
return_data($wiersz2[1])
return_data($wiersz2[2])

Pozdrawiam.
Leszek
Jan 6 '06 #3
On Fri, 06 Jan 2006 16:37:02 +0100, Beauregard T. Shagnasty
<a.*********@example.invalid> wrote:
Is this what you mean? <tr> starts a new row; you do not want to put
each "column" in its own row.


<prediction>
Next question: How do I display the data cells in a table underneith one
an other, like it was a column (instead next to eachother in a row)?
</prediction>


--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Jan 6 '06 #4
Leszek wrote:
I wrote a php script that reads some dara from database and displays it as
a table:
The problem is that the data are showing in table rows Is it possible to
display it as a new colum next to an existing one?
Here is php code::
echo "<table align=\"center\" width=\"100%\">";
echo"<tr><td>Room:</td></tr>";
echo"<tr><td>Price:</td></tr>";
echo"<tr><td>How many rooms?:</td></tr>";

// data display

$wynik2=mysql_query($hotel_query2);
while($wiersz2=mysql_fetch_array($wynik2,MYSQL_NUM ))
{
echo"<tr><td>".return_data($wiersz2[0])."</td></tr>";
echo"<tr><td >".return_data($wiersz2[1])."</td></tr>";
echo"<tr><td >".return_data($wiersz2[2])."</td></tr>";
}
echo "</table>";

Each while pass creates 3 rows. Is it possible to make new column (with 3
rows) next to the one that already exists?

Thanks.
Leszek


Leszek,

Hint:
echo "<tr> <td>Room:</td> <td>".return_data($wiersz2[0])."</td> </tr>";

Cheers,
Carl.
Jan 6 '06 #5
Barbara de Zoete wrote:
On Fri, 06 Jan 2006 16:37:02 +0100, Beauregard T. Shagnasty
<a.*********@example.invalid> wrote:
Is this what you mean? <tr> starts a new row; you do not want to
put each "column" in its own row.


<prediction> Next question: How do I display the data cells in a
table underneith one an other, like it was a column (instead next to
eachother in a row)? </prediction>


You are probably correct. :-0
echo "<table align=\"center\" width=\"100%\">";
// data display
$wynik2=mysql_query($hotel_query2);
while($wiersz2=mysql_fetch_array($wynik2,MYSQL_NUM ))
{
echo"<tr><td>Room:</td><td>.return_data($wiersz2[0])."</td></tr>";
echo"<tr><td>Price:</td><td >".return_data($wiersz2[1])."</td></tr>";
echo"<tr><td>How many
rooms?:</td><td>".return_data($wiersz2[2])."</td></tr>";
}
echo "</table>";
This of course means Leszek only ever expects three items to be returned
by the query. The above is not the normal way to display a table of data.

--
-bts
-Warning: I brake for lawn deer
Jan 6 '06 #6
Leszek wrote:
I want to get this:

//Column1 Column2
Room: return_data($wiersz2[0])
Price: return_data($wiersz2[1])
How many?: return_data($wiersz2[2])

But using my code i'm getting:

Room:
Price:
How many?:
return_data($wiersz2[0])
return_data($wiersz2[1])
return_data($wiersz2[2])

Pozdrawiam.
Leszek


Two basic ways of handling this. One is a html solution, the other array
based.

HTML Solution:
Nested tables.
<table>
<tr>
<td>
<table><tr><td>Room:</td></tr><tr><td>Price</td></tr><tr><td>How
many?:</td></tr></table>
</td>
<td>
<table><tr><td>return_data($wiersz
[0])</td></tr><tr><td>return_data($wiersz
[1])</td></tr><tr><td>return_data($wiersz2[2])</td></tr></table>
</td>
</tr>
</table>

Array based:

/* Toss both sets of values (labels and data) into arrays */
$labels=array('Room:','Price:','How many?:');
$column[1]=array(return_data($wiersz2[0]),return_data($wiersz
[1]),return_data($wiersz2[3]));
$column[2]=array(return_data($ziersz2[0]),return_data($ziersz
[1]),return_data($ziersz2[2]));

echo("<table>");
for($i=0;$i<=(count($labels)-1);$i++){
echo("<tr><td>{$labels[$i]}</td>");
foreach($column AS $col){
<td>$col[$i]</td>
}
echo("</tr>");
}
echo("</table>");
Jan 7 '06 #7
Leszek wrote:
I wrote a php script that reads some dara from database and displays it as
a table:
The problem is that the data are showing in table rows Is it possible to
display it as a new colum next to an existing one?
Here is php code::
echo "<table align=\"center\" width=\"100%\">";
echo"<tr><td>Room:</td></tr>";
echo"<tr><td>Price:</td></tr>";
echo"<tr><td>How many rooms?:</td></tr>";

// data display

$wynik2=mysql_query($hotel_query2);
while($wiersz2=mysql_fetch_array($wynik2,MYSQL_NUM ))
{
echo"<tr><td>".return_data($wiersz2[0])."</td></tr>";
echo"<tr><td >".return_data($wiersz2[1])."</td></tr>";
echo"<tr><td >".return_data($wiersz2[2])."</td></tr>";
}
echo "</table>";

Each while pass creates 3 rows. Is it possible to make new column (with 3
rows) next to the one that already exists?

Thanks.
Leszek

maybe:

echo "<table align=\"center\" width=\"100%\">";

// data display

$wynik2=mysql_query($hotel_query2);
while($wiersz2=mysql_fetch_array($wynik2,MYSQL_NUM ))
{
echo "<tr><td>Room:</td><td>".return_data($wiersz2[0])."</td></tr>";
echo "<tr><td>Price:</td><td>".return_data($wiersz2[1])."</td></tr>";
echo "<tr><td>How many
rooms?:</td><td>".return_data($wiersz2[2])."</td></tr>";
}
echo "</table>";
Jan 7 '06 #8
jukka wrote:
maybe:

echo " ...


Heh, I believe you "echoed" my code from yesterday. :-)

--
-bts
-Warning: I brake for lawn deer
Jan 8 '06 #9
Beauregard T. Shagnasty wrote:
jukka wrote:

maybe:

echo " ...

Heh, I believe you "echoed" my code from yesterday. :-)

hehe pun pun. But i think your code goes:
|Room |Price |Quantity|
| 12 | $100 | 1 |

mine (or tries to):
|Room | 12|
|Price | $100|
|Quantity | 1|
Jan 8 '06 #10
jukka wrote:
Beauregard T. Shagnasty wrote:
jukka wrote:
maybe:

echo " ...


Heh, I believe you "echoed" my code from yesterday. :-)

hehe pun pun. But i think your code goes:
|Room |Price |Quantity|
| 12 | $100 | 1 |

mine (or tries to):
|Room | 12|
|Price | $100|
|Quantity | 1|


I was referring to my second post, which got sent under the name
"shagnast" (was having trouble with my usual news server at the time).
In that revision, it will print out as your "mine" example.

--
-bts
-Warning: I brake for lawn deer
Jan 8 '06 #11
Beauregard T. Shagnasty wrote:
jukka wrote:

Beauregard T. Shagnasty wrote:
jukka wrote:
maybe:

echo " ...

Heh, I believe you "echoed" my code from yesterday. :-)


hehe pun pun. But i think your code goes:
|Room |Price |Quantity|
| 12 | $100 | 1 |

mine (or tries to):
|Room | 12|
|Price | $100|
|Quantity | 1|

I was referring to my second post, which got sent under the name
"shagnast" (was having trouble with my usual news server at the time).
In that revision, it will print out as your "mine" example.

ah yes, i see it now :)
Jan 9 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user...
5
by: javaguy | last post by:
I have a data entry web application that is formatted heavily with tables. Having learned a bit of CSS, I'm hoping to rewrite this using <div> tags. But I have run into a formatting problem that...
20
by: Neil | last post by:
I have an Access 2000 MDB file with a SQL 7 back end. I have a main table with 50,000 records; and I have a selections table with 50,000 records for each machine that uses the database (about...
3
by: news.microsoft.com | last post by:
I am using client script to handle some XML stuff with MS XMLDOM But I ran into a problem in selecting the elements using selectNodes method The XML looks like: <root> ...........................
2
by: DataB | last post by:
Hi everyone! I have a forms problem. Bakground: I have created a number of tables. Of these, I have a main parent table (Personal Details) and a number of other child tables (Tax file No.,...
4
by: Dave | last post by:
Hey guys, I have an ODBC problem that has me stumped. I wrote a VBA script to run in Microsoft Excel that pulls data out of an application using that application's ODBC driver and puts it into...
12
by: Riley DeWiley | last post by:
I have a project that is using a Jet backend and having trouble with Jet's tendency to bloat it's MDB file. I can compact it but it is a hassle. I am considering switching to a Fox backend but have...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
9
by: QCLee | last post by:
Sir can you help me to transfer my Access Query to MS excel? i have a command button on the form to export the parameter query named "HVACWindwardQuery" to excel spreadsheet and i got the codes...
10
by: amitabh.mehra | last post by:
Hi I havent used MQT before. Read the online tips and tutorials but none seems to give any hint for my problem. I have a base table (base_table) as: st varchar(25) default...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.