table interview questions
Top table frequently asked interview questions
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)
What are the differences between PRIMARY, UNIQUE, INDEX and FULLTEXT when creating MySQL tables?
How would I use them?
Source: (StackOverflow)
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 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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)