Hi,
I have just started coding in PHP. I have coded a web page using HTML, JS, and PHP. An HTML table has to be populated dynamically using the data from the backend.
Presently I have 5 records in the backend table so I get 5 HTML-table rows. I have created a session object starting from the login page. The requirement is that as soon as I log in and my request gets forwarded to the foll PHP page I should be seeing the foll. dynamically generated table. This portion has been done.
The next part is that the very first time my request gets forwarded to the foll PHP page, only the first row's [i.e. Job Attribute Hierarchy (see pic)] Go-button and textbox should be enabled, the remaining rows' textboxes and buttons should be disabled.
When I enter the data in the first row's textbox and hit 'Go'.. I come to another PHP page where in I fill some more data and hit 'OK' thereby coming back to the foll. PHP page. At this time the first row should have its textbox and Go-buttons disabled and there should be a tickmark on the first cell of the row. At this time only the second row's textbox and Go-button should be enabled and 1,3,4,5 row's elements should be disabled. Again the same procedure repeats... I hit the Go button on second row [Job Rewards/Culture Hierarchy (see pic)].. and my request gets forwarded to some other page where I hit OK and come back to the foll PHP page. This time there is a tickmark on the second row's first cell and it's textbox and Go-button are disabled alongwith those of row's 1,2,4,5 and only row 3's elements are enabled... and so on..
I believe I should be setting a flag variable as a session attribute to achieve this, but I am not getting a clear idea as to how I should use this flag to dynamically enable-disable the textboxes and Go-buttons. Any suggestions?
Regards,
sasha
[PHP]
<?php
session_start();
$flag = 0;
if(!isset ($_SESSION['flag']))
{
$flag = 1;
$_SESSION['flag'] = $flag;
}
else
{
$flag++ ;
$_SESSION['flag'] = $flag;
}
?>
<html>
<body>
<table align = "center" id = "TID" border = "1" cellpadding = "3" cellspacing = "3">
<?php
$selectMasterAttributes = "select * from MasterAttributes ;" ; // select all columns(Name,NameId,Active)
$selectMasterAttributes_result = mysql_query($selectMasterAttributes) or die("Error with $selectMasterAttributes ");
if(mysql_num_rows($selectMasterAttributes_result) > 0)// proceed with the dynamic attribute-row-creation only if backend attribute table contains any attributes
{
while($row = mysql_fetch_array($selectMasterAttributes_result))
{
$MAttrName = $row['Name'];
//echo $MAttrName . '<br>' ;
$MAttrNameId = $row['NameId'];
//echo $MAttrNameId . '<br>';
$MAttrActive = $row['Active'];
//echo $MAttrActive . '<br>' ;
echo '<tr id = "' . $MAttrNameId . '">';
echo '<td bgcolor = "orange">' . $MAttrNameId . '</td>';
echo '<td>' . $MAttrName . '</td>';
echo '<td ><input type = "text" size = "5" id = "Attr'. $MAttrNameId .'" name = "Attr'. $MAttrNameId .'"></td>';
echo '<td><input type = "submit" name = "go' . $MAttrNameId . '" value = "Go" onclick = "set_attr_name(this.name)"></input></td>';
echo '</tr>';
}
}// (mysql_num_rows($selectMasterAttributes_result) > 0) over
else
{
echo '<tr><td colspan = "4"> No Attributes Present in backend</td></tr>' ;
}
?>
</table>
</body>
</html>
[/PHP]