<table border>
<thead>
<td>ПН</td>
<td>ВТ</td>
<td>СР</td>
<td>ЧТ</td>
<td>ПТ</td>
<td>СБ</td>
<td>ВС</td>
</thead>
<tr id="state">
<td>Выходной</td>
<td>Выходной</td>
<td>Выходной</td>
<td>Выходной</td>
<td>15-21</td>
<td>15-21</td>
<td>16-21</td>
</tr>
</table>
var
$Table = $("<table />"),
$Thead = $("<thead />").appendTo($Table),
$Row = $("<tr />").appendTo($Table),
$_tds = $("#state td"), $_heads = $("thead td"),
start, i = 0;
for(; i < $_tds.length; i++){
start = i;
while(
$_tds.get(i++) && $_tds.eq(i).text() == $_tds.eq(i - 1).text()
){}
$Row.append(
"<td>" + $_tds.eq(--i).text() + "</td>"
);
$Thead.append(
"<td>" + (i == start ? "" : $_heads.eq(start).text() + "-") + $_heads.eq(i).text() + "</td>"
);
}
$("table").replaceWith($Table);
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
</tbody>
</table>
if(isset($_POST['queryString'])) {
if( array_key_exist( 'queryString', $_POST)) {
$query = $db->query("SELECT name FROM MS_store WHERE name LIKE '$queryString%' LIMIT 10");
инъекцияecho '</li><li onclick="fill(''
echo "</li><li onclick=\"fill( '{$result->value}');\">{$result->value}</li>";
хотя бы так