473,385 Members | 1,587 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,385 software developers and data experts.

How to code <table> arguments within PHP

40
OK, I'm back again.

On one of my PHP pages, I build a table using the following code snippet:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     echo "<table><THEAD><tr>";
  3.     echo "<td><b>Incident</b></td>";
  4.     echo "<td><b>Facility</b></td>";
  5.     echo "<td><b>Location</b></td>";
  6.     echo "<td><b>Person</b></td>";
  7.     echo "<td><b>Injury</b></td>";
  8.     echo "<td><b>Severity</b></td>";
  9.     echo "<td><b>Incident Date</b></td></tr></THEAD>";
  10.     while ($myrow = mysql_fetch_array($result))
  11.     {
  12.        echo "<TBODY><tr><td>".$myrow["incident_id"]."</td>";
  13.        echo "<td>&nbsp ".$myrow["fac_id"]."</td>";
  14.        echo "<td>&nbsp ".$myrow["room_descr"]."</td>";
  15.        echo "<td>&nbsp ".$myrow["person_type"]."</td>";
  16.        echo "<td>&nbsp ".$myrow["injury"]."</td>";
  17.        echo "<td>&nbsp ".$myrow["severity"]."</td>";
  18.        echo "<td>&nbsp ".$myrow["inc_date"]."</td>";
  19.     }
  20.        echo "</tr></TBODY></table>";
  21. ?>
  22.  
It works fine, but I am unable to add the other arguments to <table> such as border, class, etc.

I worked around this on one file by jumping out of php and coding the html <table> arguments and then jumping back into php to echo the data, but there must be a better way to do this.

Is there a way to enter the table arguments within php? I want something like
Expand|Select|Wrap|Line Numbers
  1. <table border name='Mytable class'='sortable'>
  2.  
Thanks,
jej1216
Jun 6 '07 #1
4 1292
pbmods
5,821 Expert 4TB
Are you trying to dynamically add these attributes at runtime, or do you need to make a one-time upgrade?
Jun 6 '07 #2
jej1216
40
Are you trying to dynamically add these attributes at runtime, or do you need to make a one-time upgrade?
I want to make a coding change that will be static - one time. I mainly want to add the border argument so the table has a better appearance.
Jun 6 '07 #3
jej1216
40
I withdraw the question - it works fine. I guess I fat-fingered it before.

Sorry.
Jun 6 '07 #4
OK, I'm back again.
...snip...
I worked around this on one file by jumping out of php and coding the html <table> arguments and then jumping back into php to echo the data, but there must be a better way to do this.

Is there a way to enter the table arguments within php? I want something like
Expand|Select|Wrap|Line Numbers
  1. <table border name='Mytable class'='sortable'>
  2.  
Thanks,
jej1216
If I understand your quest, you just do not like to break-up your output strings in the middle to accommodate your php variable data. If this is right, the the following may be helpful.
PHP allows you to use two types of QUOTEs : the single-quotes and the double quotes.
Generally single-quotes are non-variable accommodating while the double-quotes are variable accommodating. It means that you can put in the variables in your strings. Like this:
[PHP]
$var1 = 2;
echo "There are $var1 ways to create a string in PHP";
# This outputs : There are 2 ways to create a string in PHP
[/PHP]
or may be like the following if you are worried about the array presentation.
[PHP]
$var2 = "two";
$var3 =array("single" => 1, "double"=>2);
echo "Double quote has $var2 sets of $var['double'] apostrophes."
# OUTPUT : Double quote has two sets of 2 apostrophes.
[/PHP]
Hoe this gives you some idea to go further.
Jun 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
8
by: bearclaws | last post by:
I am looping through a list of categories and want to display the list horizontally (instead of vertically). I want to create a single row with 4 list items in each cell of the row. I thought...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
0
by: timnels | last post by:
I've got a bizzare issue where I have an XML file to load into a data set like: <conversion> <table name="parent"> <table name="child"> </table> </table> <table name="another parent"> ....
1
by: Markusek Peter | last post by:
How can I call JavaScript function within <TABLE> tags. I've got <table width="here should be return value from js script"> Thank you.
1
by: prefersgolfing | last post by:
I'm not using Master Pages, yet I'd like to display the contents of an HTML page within a <table><tr><td> on a .aspx. I have a lengthy guide already paginated in html. I'd like to embed the...
0
by: =?Utf-8?B?R3JlZw==?= | last post by:
I've created my table and alli is fine. I name my <tdtags to make them easier to identify when my table gets large. Anyway, I am naming as such: <td id="cellName" > Now, sometimes when make a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
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...
1
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...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

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.