I’ve got few iterations through the database like:
<?php
$test = mysql_query("SELECT * FROM test WHERE id='1'");
while($row = mysql_fetch_array($test))
{
echo "<tr>";
echo "<td>" . $row['value'] . "</td>";
echo "<td><input type='text' id='datepicker' /></td>";
echo "<td><button id='save'>Save</button></td>";
echo "</tr>";
}
?>
<?php
$test = mysql_query("SELECT * FROM test WHERE id='2'");
while($row = mysql_fetch_array($test))
{
echo "<tr>";
echo "<td>" . $row['value'] . "</td>";
echo "<td><input type='text' id='datepicker' /></td>";
echo "<td><button id='save'>Save</button></td>";
echo "</tr>";
}
?>
The problem is with the jQuery datepicker. It works only for the first input, like when the test table returns for example 3 entries (e.g., mysql,datepicker,save; oracle,datepicker,save; db2,datepicker,save), datepicker works only for the first input when I click it (like for oracle,datepicker,save) but not for the rest. Any idea how to populate it for every listed input based on table elements in scope of one while?
instead of breaking your query to the molecular level, use a single SQL Statement, and a single loop: