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

PHP Variable in HTML Table Cell

In a PHP window that includes an HTML table, how do you put the value of the PHP variable in a table cell?
Apr 21 '13 #1
4 3069
Rabbit
12,516 Expert Mod 8TB
I'm not sure what your question is. There's no difference in how you echo a variable in or out of a table cell. You must have an additional complication that you have not told us about.
Apr 21 '13 #2
@Rabbit
I got the value I need into a PHP variable with $uid = $_POST['uid'] and can echo the value of $uid to the window; now I want to put the value into an HTML table cell. Are you saying I should include value=<?php echo $uid ?> when defining the table cell? I do not under stand your phrase 'There's no difference in how you echo a variable in or out of a table cell' how DO you echo a variable in or out of a table cell?
Apr 22 '13 #3
Rabbit
12,516 Expert Mod 8TB
An example when you're not doing it in a table cell:
Expand|Select|Wrap|Line Numbers
  1. <div><? echo $variable; ?></div>
An example when you're doing it in a table cell:
Expand|Select|Wrap|Line Numbers
  1. <td><? echo $variable; ?></td>
There's no difference. Only the surrounding element changes.
Apr 22 '13 #4
Atli
5,058 Expert 4TB
PHP doesn't care what you are creating, whether it's a HTML link, HTML table, HTML paragraph, XML elements, JavaScript code, or even things like binary strings. It's all just a bunch of text as far as PHP is concerned. You can put a echo statement wherever you want.

But, just to point one thing out. If you are putting PHP values originating from user input into a HTML page, be sure to run it through htmlentities first. Also, if the values are going into HTML element attributes (like the <input> value attribute), then surround them with quotes.
Expand|Select|Wrap|Line Numbers
  1. // Potentially problematic and unsafe.
  2. <input value=<?php echo $variable; ?>>
  3.  
  4. // Less problematic, but still unsafe.
  5. <input value="<?php echo $variable; ?>">
  6.  
  7. // Safe and not at all problematic.
  8. <input value="<?php echo htmlentities($variable, ENT_QUOTES, "UTF-8"); ?>">
  9.  
Apr 23 '13 #5

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

Similar topics

3
by: 18k11tm001 | last post by:
I would like to place a diagonal line in the upper-left cell of an HTML table, with one word above it and one word below it to label the rows and columns. Can anyone tell me a reasonably simple way...
1
by: ven | last post by:
hello i have problem with response.redirect method, namely i have default page home.aspx where is html table : <%@ Page Language="VB" %> <script runat="server"> ' Insert page code here '
4
by: KatB | last post by:
Hi, in order to format my web page, I'm starting to use Flow layout so using html tables to space out controls, etc. When using grid layout, the following worked when it was just a datagrid. I...
5
by: Michael | last post by:
Is there a way to specify a background-image for a html table cell in a theme's css file. I know a lot of things I can't do... can't figure out one that I can do: 1) ~/ Images/logo.gif...
3
by: Ravi Kondamuru | last post by:
Hi, I am using a table to create a layout. It basically splits the browser into two. In one of the cell's I would like to load a webpage. How can I do that? Do I have to use something else to create...
10
by: Greg Lovern | last post by:
I have a very large html table created by MS Word, saved as it's "Web Page, Filtered" file type. Every html table cell has lots of formatting tags. Most of the file size is that formatting. Is...
3
by: markszlazak | last post by:
Firefix works fine but I'm having a problem inserting a DIV into a HTML table cell dynamically with IE 6. The following code has a two cell table with one DIV hard-coded into the first (top) cell...
8
by: James Kimble | last post by:
Yeah I'm sure this is a stupid question. I've got a javascript source file with functions (creates a bar graph) I want to call from inside an html table cell so that the graph appears in the...
1
by: webandwe | last post by:
Hi, I'm new to asp and searched the web for 4 hour now and can't find what I want to do. What I want do is get all details form the database and put them in an vairabil or something and then just...
2
aas4mis
by: aas4mis | last post by:
I have a table that I want a,b,c,d,e,f,g,h,and m for headers and 26 rows. In the values I want to verify against a mysql query. If cell A3 is in the list I want to highlight it yellow (or put an X...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: 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

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.