It's a pretty big project because it's going to be used by a large audience and it's expected to grow big with time. I started the form so users can enter information about the school materials and it was going fine until I noticed the sections with dynamic check boxes are missing the first option on the list from mysql. This is the script I'm using overall, but the checkbox script is highlighted in red:
<?php
include("../Connections/connect.php");
$lables = array( "first_name" => "First name",
"last_name" => "Last name",
"title" => "Title",
"affiliation" => "Affiliation",
"uni" => "Uni",
"center" => "Institution",
"street_addr" => "Address*",
"city" => "City",
"state" => "State",
"zip_code" => "Zip code",
"email" => "Email",
"entry_date" => "Date",
"prod_title" => "Product Title",
"description" => "Description",
"annotation" => "Annotation",
"topics" => "Broad Topics",
"material" => "Material",
"comp" => "Comp",
"yesorno" => "Conti",
"target" => "target",
"url_html" => "HTML Link",
"url_flash" => "Flash link",
"url_pdf" => "PDF Link",
"url_powerpoint" => "PowerPoint URL");
$query = "SELECT * from dbt_spk";
$result = mysqli_query($cnx,$query);
$row = mysqli_fetch_assoc($result);
$stquery = "SELECT * from dbt_st";
$result2 = mysqli_query($cnx,$stquery);
$row2 = mysqli_fetch_assoc($result2);
$topquery = "SELECT DISTINCT topics FROM dbt_top ORDER BY top";
$result3 = mysqli_query($cnx,$topquery);
$row3 = mysqli_fetch_assoc($result3);
$catquery = "SELECT DISTINCT material_type FROM dbt_materials ORDER BY materials";
$result4 = mysqli_query($cnx,$catquery);
$row4 = mysqli_fetch_assoc($result4);
$compquery = "SELECT DISTINCT comp_level FROM dbt_comp ORDER BY comp";
$result5 = mysqli_query($cnx,$compquery);
$row5 = mysqli_fetch_assoc($result5);
$contiquery = "SELECT DISTINCT yesorno FROM dbt_conti ORDER BY yesorno";
$result6 = mysqli_query($cnx,$contiquery);
$row6 = mysqli_fetch_assoc($result6);
$urlquery = "SELECT * FROM dbt_url";
$result7 = mysqli_query($cnx,$urlquery);
$row7 = mysqli_fetch_assoc($result7);
echo "<div align='center'>";
echo "<h3>Update resource information below</h3>";
echo "<form action='checkupdate.php?update' method='POST'><table>\n
<tr><td class='required_fields'>$lables[first_name] </td><td> <input type='text' name='first_name' value='$row[first_name]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[last_name] </td><td> <input type='text' name='last_name' value='$row[last_name]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[title] </td><td> <input type='text' name='title' value='$row[title]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[affiliation] </td><td> <input type='text' name='affiliation' value='$row[affiliation]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[uni] </td><td> <input type='text' name='uni' value='$row[uni]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[center] </td><td> <input type='text' name='center' value='$row[center]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[street_addr] </td><td> <input type='text' name='street_addr' value='$row[street_addr]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[city] </td><td> <input type='text' name='city' value='$row[city]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='required_fields'>$lables[state] </td><td> <select name'state'><option value='No database selected' selected>Select a state";
//build state list
while($row2 = mysqli_fetch_assoc($result2))
{
extract($row2);
echo "<option value'$row[states]'>$row2[states]";
}
echo "</select></td></tr>";
echo "<tr><td class='required_fields'>$lables[zip_code] </td><td> <input type='text' name='zip_code' value='$row[zip_code]' size='11' maxlength='11'> </td></tr>\n
<tr><td class='required_fields'>$lables[email] </td><td> <input type='text' name='email' value='$row[email]' size='30' maxlength='30'> </td></tr>\n
<tr><td class='body' >$lables[entry_date] </td><td>";
$monthName = array(1=>"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$today = time(); //stores today's date
$f_today = date("M-d-Y",$today); //format today's date
#echo "Today is $f_today\n";
//selection list for month
$todayMO = date("n",$today); //get the month from $today
echo "<select name='dateMO'>\n";
for($n=1;$n<=12;$n++)
{
echo "<option value=$n\n";
if ($todayMO == $n)
{
echo " Selected";
}
echo "> $monthName[$n]\n";
}
echo "</select>\n";
//selection list for the day
$todayDay = date("d",$today);
echo "<select name='dateDay'>\n"; //get the day from $today
for($n=1;$n<31;$n++)
{
echo " <option value=$n";
if ($todayDay == $n)
{
echo " Selected";
}
echo "> $n\n";
}
echo "</select>";
//selection list for the day
$startYr = date("Y",$today); //get the year from $today
echo "<select name='dateYr'>\n";
for($n=$startYr;$n<=$startYr+3;$n++)
{
echo " <option value=$n";
if($startYr == $n)
{
echo " Selected";
}
echo "> $n\n";
}
echo "</select></td></tr>\n";
echo "<tr><td class='required_fields'>$lables[prod_title] </td><td> <input type='text' name='prod_title' value='$row[prod_title]' size='50' maxlength='100'> </td></tr>\n
<tr><td class='required_fields' valign='top'>$lables[description]</td><td><textarea name='zip_code' rows='4' cols='38'>$row[description]</textarea> </td></tr>\n
<tr><td class='required_fields'>$lables[annotation] </td><td> <input type='text' name='anotation' value='$row[annotation]' size='30' maxlength='30'> </td></tr>\n
<tr><td colspan='2'><hr></hr></td></tr>";
//building checkboxes for topics
echo "<tr><td class='required_fields' valign='top'>$lables[topics] </td><td class='checkboxes'>";
while ($row3 = mysqli_fetch_assoc($result3))
{
extract($row3);
echo "<input type='checkbox' name='$row[topics]' value='$row3[topics]'>$row3[topics]<br>\n";
}
echo "</td></tr>\n";
//building checkboxes for material
echo "<tr><td class='required_fields' valign='top'>$lables[material] </td><td class='checkboxes'>";
while ($row4 = mysqli_fetch_assoc($result4))
{
extract($row4);
echo "<input type='checkbox' name='$row[material]' value='$row4[material]'>$row4[material_type]<br>\n";
}
echo "</td></tr>\n";
//build the comp
echo "<tr><td class='required_fields' valign='top'>$lables[competency_level] </td><td class='checkboxes'>";
while ($row5 = mysqli_fetch_assoc($result5))
{
extract($row5);
echo "<input type='checkbox' name='$row[comp]' value='$row5[comp]'>$row5[comp]<br>\n";
}
echo "</td></tr>\n";
//build the conti
echo "<tr><td class='required_fields' valign='top'>$lables[conti] </td><td class='checkboxes'>";
while ($row6 = mysqli_fetch_assoc($result6))
{
extract($row6);
echo "<input type='checkbox' name='$row[yesorno]' value='$row6[yesorno]'>$row6[yesorno]<br>\n";
}
echo "</td></tr>\n";
echo "<tr><td class='required_fields'>Resource URL</td></tr><tr><td></td></tr>
<tr><td class='checkboxes' align='right'>$lables[url_html]*</td><td> <input type='text' name='$row[url_html]' value='$row7[url_html]' size='50' maxlength='255'> </td></tr>\n
<tr><td class='checkboxes' align='right'>$lables[url_pdf] </td><td> <input type='text' name='$row[url_pdf]' value='$row7[url_pdf]' size='50' maxlength='255'> </td></tr>\n
<tr><td class='checkboxes' align='right'>$lables[url_flash]</td><td> <input type='text' name='$row[url_flash]' value='$row7[url_flash]' size='50' maxlength='255'> </td></tr>\n
<tr><td class='checkboxes' align='right'>$lables[url_powerpoint]</td><td> <input type='text' name='$row[url_powerpoint]' value='$row7[url_powerpoint]' size='50' maxlength='255'> </td></tr>\n";
echo "</table></div>";
?>
It's working fine but like I said, it's not picking up the first item in the table from the db.
For now the only person login into the website is the person responsible for entering all necessary data. But eventually all users will most likely have to register and have their own logins so we can keep track of who uploaded what. Something I need help with is how to INSERT into the database all data from the form once the user clicks on submit.
papa...if you can give me suggestions on how to go about the page, i'd really appreciate it. I'm new to this so any help is very much appreciate it.