category
-catid
-catnm
subcategory
-subcatid
-subcat
-catid(fk)
point user
-pointid -userid
-point -usernm
-subcatid(fk)
-userid(fk)
The problem here i want to make it as dynamic as possible. Displaying it like this:
Category
Fruit point
Orange 3(this is a textbox where user can enter the point)
Apple 4
Banana 5
how do i name each on the text box without having to write in the code? i want it to be name when the page is loaded. not in the code. THIS IS BECAUSE if i wanted to ADD a new subcategory, i do not want to go into the code and write the name at the textbox for this new subcategory. I do not wan 2 modify the code. After the user enter the point and clicks the submit button, (same here),if there are 50 text box, i do not want to write 50 of $_POST['name'], just to get the value.
EDITED CODE for simplicity:
<?php
//display category
$sql="SELECT FROM category";
$result=mysql_query($sql, $db) or die("Could not execute query 1");
while($row=mysql_fetch_array($result))
{
//display subcategory
$defination="SELECT FROM subcategory WHERE catid=".$row['catid'];
$resultdef=mysql_query($defination, $db) or die("Could not execute query 2");
while($rowdef=mysql_fetch_array($resultdef))
{
$subcat=$rowdef['subcat'];
echo "<td><input type=\"text\" name=\"$subcat\" value=\"\"></td>";
}
}
?>
Note this: name=\"$subcat\" Can this be done to name the textfield? or use an array with array of array [][]? or any ideas please..valid?
After submit at the processing page, (thinking of using the same looping structure like above and make it like this $POST['$subcat'] to retrive the point. But it comes out error. I think its becoz of this-> $subcat. Its not valid right? How to retrieve each of the text field without having to write 50 times of $POST?