EzDevInfo.com

table interview questions

Top table frequently asked interview questions

Why is textarea filled with mysterious white spaces?

I have a simple text area in a form like this:

<textarea style="width:350px; height:80px;" cols="42" rows="5" name="sitelink">
    <?php if($siteLink_val) echo $siteLink_val; ?> 
</textarea>

I keep getting extra white space in this textarea. When I tab into it my cursor is like in the middle of the textarea and not in the beginning? What is the explanation?


Source: (StackOverflow)

Select all 'tr' elements except first 'tr' in a table with CSS

How can I select all tr elements except for the first tr in a table with CSS?

I tried using this method but found that it did not work:

http://www.daniel-lemire.com/blog/archives/2008/08/22/how-to-select-even-or-odd-rows-in-a-table-using-css-3/


Source: (StackOverflow)

Advertisements

Differences between INDEX, PRIMARY, UNIQUE, FULLTEXT in MySQL?

What are the differences between PRIMARY, UNIQUE, INDEX and FULLTEXT when creating MySQL tables?

How would I use them?


Source: (StackOverflow)

Set the table column width constant regardless of the amount of text in its cells?

In my table I set the width of the first cell in a column to be 100px.
However, when the text in one of the cell in this column is too long, the width of the column becomes more than 100px. How could I disable this expansion?


Source: (StackOverflow)

In HTML5, with respect to tables, what replaces cellpadding, cellspacing, valign, and align?

In Visual Studio, I'm seeing these warnings:

  • Validation (HTML 5): Attribute 'cellpadding' is not a valid attribute of element 'table'.
  • Validation (HTML 5): Attribute 'cellspacing' is not a valid attribute of element 'table'.
  • Validation (HTML 5): Attribute 'valign' is not a valid attribute of element 'td'.
  • Validation (HTML 5): Attribute 'align' is not a valid attribute of element 'td'.

If they are not valid attributes in HTML5, what replaces them in CSS?


Source: (StackOverflow)

Tools for making latex tables in R [closed]

On general request, a community wiki on producing latex tables in R. In this post I'll give an overview of the most commonly used packages and blogs with code for producing latex tables from less straight-forward objects. Please feel free to add any I missed, and/or give tips, hints and little tricks on how to produce nicely formatted latex tables with R.

Packages :

  • xtable : for standard tables of most simple objects. A nice gallery with examples can be found here.
  • memisc : tool for management of survey data, contains some tools for latex tables of (basic) regression model estimates.
  • Hmisc contains a function latex() that creates a tex file containing the object of choice. It is pretty flexible, and can also output longtable latex tables. There's a lot of info in the help file ?latex
  • miscFuncs has a neat function 'latextable' that converts matrix data with mixed alphabetic and numeric entries into a LaTeX table and prints them to the console, so they can be copied and pasted into a LaTeX document.
  • texreg package (JSS paper) converts statistical model output into LaTeX tables. Merges multiple models. Can cope with about 50 different model types, including network models and multilevel models (lme and lme4).
  • reporttools package (JSS paper) is another option for descriptive statistics on continuous, categorical and date variables.
  • tables package is perhaps the most general LaTeX table making package in R for descriptive statistics
  • stargazer package makes nice comparative statistical model summary tables

Blogs and code snippets

Related questions :


Source: (StackOverflow)

CSS text-overflow in a table cell?

I want to use CSS text-overflow in a table cell, such that if the text is too long to fit on one line, it will clip with an ellipsis instead of wrapping to multiple lines. Is this possible?

I tried this:

td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

But the white-space: nowrap seems to make the text (and its cell) continually expand out to the right, pushing the total width of the table beyond the width of its container. Without it, however, the text continues to wrap to multiple lines when it hits the edge of the cell.


Source: (StackOverflow)

jQuery table sort

I have a very simple HTML table with 4 columns:

Facility Name, Phone #, City, Specialty

I want the user to be able to sort by Facility name, and City only.

How can I code this using jQuery?


Source: (StackOverflow)

Setting table column width

I've got a simple table that is used for an inbox as follows:

<table border="1">
    	<tr>
    		<th>From</th>
    		<th>Subject</th>
    		<th>Date</th>
    	</tr>

How do I set the width so the From and Date are 15% of the page width and the Subject is 70%. I also want the table to take up the whole page width.


Source: (StackOverflow)

Add timestamps to an existing table

I need to add timestamps(created_at updated_at) to an existing table. I tried the following code but it didn't work. I have also tried other solutions I found online but they don't work either.

class AddTimestampsToUser < ActiveRecord::Migration
    def change_table
      add_timestamps(:users)
    end
end

How can I do it?


Source: (StackOverflow)

Alternate table row color using CSS?

I am using a table with alternate row color with this.

tr.d0 td {
  background-color: #CC9999;
  color: black;
}
tr.d1 td {
  background-color: #9999CC;
  color: black;
}
<table>
  <tr class="d0">
    <td>One</td>
    <td>one</td>
  </tr>
  <tr class="d1">
    <td>Two</td>
    <td>two</td>
  </tr>
</table>

Here I am using class for tr, but I want to use only for table. When I use class for table than this apply on tr alternative.

Can I write my HTML like this using CSS?

<table class="alternate_color">
    <tr><td>One</td><td>one</td></tr>
    <tr><td>Two</td><td>two</td></tr>
    </table>

Is there a way to do like this?


Source: (StackOverflow)

How to wrap text in LaTeX tables?

I am creating a report in LaTeX which involves a few tables. I'm stuck on that as my cell data in the table is exceeding the width of the page. Can I somehow wrap the text so that it falls into the next line in the same cell of the table?

Is it somehow related to the table's width? But as it's overshooting the page's width, it won't make a difference, will it?


Source: (StackOverflow)

how to make a whole row in a table clickable as a link?

is it possible to make a whole row clickable as a link? I'm using bootstrap andthe following doesn't work:

<tbody>
    <a rel='nofollow' href="#">
        <tr>
            <td>Blah Blah</td>
            <td>1234567</td>
            <td>£158,000</td>
        </tr>
    </a>
</tbody>

Source: (StackOverflow)

HTML input textbox with a width of 100% overflows table cells

Does anyone know why the input elements with a width of 100% go over the table's cells border. In the simple example below input box go over the table's cells border, the result is horrible. This was tested and it happens in the same way on: FF, IE7 and Safari. Does it make sense for you? Am I missing something, do you know about a possible solution?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">    
<html><head>    
   <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <!-- don't use closing slash in meta tag, it breaks HTML4.01 transitional -->
   <title>Test input text in table</title>
   <style type="text/css">      
      table {border-top: 1px solid #ff0000; border-left: 1px solid #ff0000;}
      table td {border-right: 1px solid #00ff00; border-bottom: 1px solid #00ff00;}
      input[type="text"] {width: 100%;} /* removing this would make input not to go over cells border, but they would be too short, I want them to fit cells size */
   </style>    
</head><body>

<table cellpadding="0" cellspacing="0">
   <tr>
      <td><p>column one hello babe babe babe</p></td>
      <td><p>column two hello babe more</p></td>
      <td><p>column three hello babe more and more</p></td>
   </tr>
   <tr>
      <td><input type="text" value="test"></td>
      <td><input type="text" value="test"></td>
      <td><input type="text" value="test"></td>
   </tr>
</table>

</body></html>

Source: (StackOverflow)

Most efficient way to determine if a Lua table is empty (contains no entries)?

What's the most efficient way to determine if a table is empty (that is, currently contains neither array-style values nor dict-style values)?

Currently, I'm using next():

if not next(myTable) then
    -- Table is empty
end

Is there a more efficient way?

Note: The # operator does not suffice here, as it only operates on the array-style values in the table - thus #{test=2} is indistinguishable from #{} because both return 0. Also note that checking if the table variable is nil does not suffice as I am not looking for nil values, but rather tables with 0 entries (i.e. {}).


Source: (StackOverflow)