(PHP MYSQL) Updating html table row to mysql database - php

I have create an HTML table that displays information from a MySQL table with PHP. Here is my current code:
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Program</th>
<th>Class</th>
</tr>
<?php
$db = JFactory::getDBO();
$query = "SELECT * FROM student_management_module";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as &$row) {
echo "<tr>";
echo "<td>" . "<input type=text name=fullName id=name_val value=" .$row->name. "> </td>";
echo "<td>" . "<input type=text name=email id=email_val value=" .$row->email. "> </td>";
echo "<td>" . "<input type=text name=prog id=prog_val value=" .$row->program. "> </td>";
echo "<td>" . "<input type=text name=class id=class_val value=" .$row->class. "> </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .$row->student_id. "> </td>";
echo "</tr>";
}
?> </table>
I want to add an update function that sends a row of edited information from the html table to the database. I've tried using HTML forms but they only be used to send the entire table of information or a singular cell of information.
Any help would be much appreciated!

Related

HTML: putting a table in a form

I'm coding an html table that displays information from a MySql table. Each row is a series of input's so the values of the table can be easily updated.
Here's my current code:
<form action=index.php/component/studentmanagement/?task=update method=post>
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Program</th>
<th>Class</th>
</tr>
<?php
$db = JFactory::getDBO();
$query = "SELECT * FROM student_management_module";
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as &$row) {
echo "<tr>";
echo "<td>" . "<input type=text name=fullName id=name_val value=" .$row->name. "> </td>";
echo "<td>" . "<input type=text name=email id=email_val value=" .$row->email. "> </td>";
echo "<td>" . "<input type=text name=prog id=prog_val value=" .$row->program. "> </td>";
echo "<td>" . "<input type=text name=class id=class_val value=" .$row->class. "> </td>";
echo "<td class = 'headcol'> <input type=submit name=update class='btnupdate' value=update>";
echo "<td>" . "<input type=hidden name=hidden value=" .$row->student_id. "> </td>";
echo "</tr>";
}
?>
</table> </form>
But whenever I try submitting the updated values, they don't get pass to my update functions. Am I putting the table in the form correctly?
Thanks in advance, and I'll appreciate any help.
This is my update function:
<?php
$db = JFactory::getDBO();
$query = "UPDATE student_management_module SET name = '$_POST[fullName]', email = '$_POST[email]', program='$_POST[prog]', class='$_POST[class]' WHERE student_id='$_POST[hidden]'";
$db->setQuery($query);
$db->query();
?>
Try having the value of the name and id in quotes or double quote. I.e., id="class_val". In your case, since you have already inserted the td in a double quote, use single quote. So it will be "<td class='foo' id='foo' name='foo'></td>".

Values not Posted in the Database

I want to take attendance of a particular class and store the values in database.
I have used INNER JOIN to get the data from two tables and used those tables values in a form name attendance.
Now once i take attendance using the form i want to store that values in my database so i created another file name insertattendance.php.
The problem is it shows undefined index variables. ex.undefined index classid ..etc
so i tried using it in *if(isset($_POST['submit'])* There is no erros but the values are not posted.
My doubt is since iam using the values of my old tables is it showing error?.
Tell me how can i do this?
attendance.php
<html>
<head>
<title>grade1</title>
</head>
<body>
<table border="1" cellspacing="1" cellpadding="1" width="200" height="200">
<tr>
<th>classid</th>
<th>studentid</th>
<th>teacherid</th>
<th>locid</th>
<th>date</th>
<th>flag</th>
<th>comments</th>
</tr>
<?php
include 'conn.php';
$query = "(SELECT a.classid, a.fname, b.teacherid, c.locid
FROM class_master c JOIN student_master a
ON c.classid = a.classid JOIN teacher_link b
ON c.classid = b.classid
WHERE c.classid = 'grade1' )";
$result = mysql_query($query);
$i=1;
while( $row = mysql_fetch_array($result))
{
echo "<form action=insertattend.php method=POST>";
echo "<tr>";
echo "<td>" . "<input name=classid[$i] type=text value=" .$row['classid']." </td>";
echo "<td>" . "<input name=fname[$i] type=text value=" .$row['fname']." </td>";
echo "<td>" . "<input name=teacherid[$i] type=number value="
.$row['teacherid']." </td>";
echo "<td>" . "<input type=number name=locid[$i] value=" .$row['locid']." </td>";
echo "<td>" . "<input name=date[$i] type=date value='date'></td>";
echo "<td>" . "<input type=radio id=attend name=attend[$i] value='present'>";?>P
<?php echo "<input type=radio id=attend name=attend[$i] value='absent'>";?>A
<?php
echo"</td>";
echo "<td><input name=comment type=comment[$i] row=3 column=5></td>";
echo "</tr>";
$i++;
}
?>
</table>
<input type="submit" value="submit">
</form>
</body>
</html>
Here is my Insertattendance.php code
<?php
if (isset($_POST['submit'])){
include 'conn.php';
$clnm = mysql_real_escape_string($_POST['classid']);
$stfn = mysql_real_escape_string($_POST['fname']);
$dt = mysql_real_escape_string($_POST['date']);
$fg = mysql_real_escape_string($_POST['attend']);
$tid = mysql_real_escape_string($_POST['teacherid']);
$lid = mysql_real_escape_string($_POST['locid']);
$cmt = mysql_real_escape_string($_POST['comment']);
$inquery =("INSERT INTO attendance(classid, studentid, dateid, flag, teacherid,
locid, comments) VALUES('$clnm', '$stfn', '$dt', '$fg', '$tid', '$lid', '$cmt')");
mysql_query($inquery, $dbconnection);
echo "<br>";
echo "values inserted successfully!!!!";
mysql_close($dbconnection);
};
?>
Fix your html code:
<html>
<head>
<title>grade1</title>
</head>
<body>
<table border="1" cellspacing="1" cellpadding="1" width="200" height="200">
<tr>
<th>classid</th>
<th>studentid</th>
<th>teacherid</th>
<th>locid</th>
<th>date</th>
<th>flag</th>
<th>comments</th>
</tr>
<?php
include 'conn.php';
$query = "(SELECT a.classid, a.fname, b.teacherid, c.locid
FROM class_master c JOIN student_master a
ON c.classid = a.classid JOIN teacher_link b
ON c.classid = b.classid
WHERE c.classid = 'grade1' )";
$result = mysql_query($query);
while( $row = mysql_fetch_array($result))
{
echo "<form action='insertattend.php' method='POST'>";
echo "<tr>";
echo "<td>" . "<input name=classid type=text value=" .$row['classid']." ></td>";
echo "<td>" . "<input name=fname type=text value=" .$row['fname']." ></td>";
echo "<td>" . "<input name=teacherid type=number value=" .$row['teacherid']." ></td>";
echo "<td>" . "<input type=number name=locid value=" .$row['locid']." ></td>";
echo "<td>" . "<input name=date type=date value='date'></td>";
echo "<td>" . "<input type=radio id=attend name=attend value='present'>";?>P
<?php echo "<input type=radio id=attend name=attend value='absent'>";?>A
<?php
echo"</td>";
echo "<td><input name=comment type=comment row=3 column=5></td>";
echo "</tr>";
//echo "</form>";
?>
<input type="submit" name="submit" value="submit">
</form>
<?php } ?>
<!--<form action="insertattend.php">-->
</table>
</body>
</html>
These changes ought to be done on your attendance.php code
First move this echo "<form action=insertattend.php method=POST>"; out of your while
Actually you are closing the <form> tag before the submit button.
echo "</tr>";
echo "</form>"; //<--- Comment or Remove this line
Also, remove this line too (because you already defined above the while loop)
<form action="insertattend.php"> <!-- Remove this line -->
<input type="submit" value="submit">
</form>
Another thing is.. echo "<td><input name=comment type=comment row=3 column=5></td>"; I don't think there is something called type=comment replace that to type=text or use a <textarea>
You missed name="submit" in your attendance.php form.
<input type="submit" name="submit" value="submit">
use form opening and closing tags like this:
<html>
<head>
<title>grade1</title>
</head>
<body>
<table border="1" cellspacing="1" cellpadding="1" width="200" height="200">
<tr>
<th>classid</th>
<th>studentid</th>
<th>teacherid</th>
<th>locid</th>
<th>date</th>
<th>flag</th>
<th>comments</th>
</tr>
<?php
include 'conn.php';
$query = "(SELECT a.classid, a.fname, b.teacherid, c.locid
FROM class_master c JOIN student_master a
ON c.classid = a.classid JOIN teacher_link b
ON c.classid = b.classid
WHERE c.classid = 'grade1' )";
$result = mysql_query($query);
?>
<form action=insertattend.php method=POST>
<?php
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . "<input name='classid[]' type=text value=" . $row['classid'] . " </td>";
echo "<td>" . "<input name='fname[]' type=text value=" . $row['fname'] . " </td>";
echo "<td>" . "<input name='teacherid[]' type=number value=" . $row['teacherid'] . " </td>";
echo "<td>" . "<input type=number name='locid[]' value=" . $row['locid'] . " </td>";
echo "<td>" . "<input name='date[]' type=date value='date'></td>";
echo "<td>" . "<input type=radio id=attend name='attend[]' value='present'>";
?>P
<?php echo "<input type=radio id=attend name='attend[]' value='absent'>"; ?>A
<?php
echo"</td>";
echo "<td><input name='comment[]' type=comment row=3 column=5></td>";
echo "</tr>";
}
?>
</table>
<input type="submit" name= "submit" value="submit">
</form>
</body>
</html>
You have to post the values as array in form fields inside the loop. Then you have to get the array of post values in foreach to insert all the records to the database.
There are two forms.
Input types are in one form and submit button in another one.So avoid that and put together in one form.There is no need for another form with same action value. There are more than one student so write form outside while loop and then array name for input values. Then in php page values in array so use loop to get all values seperately.
<html>
<head>
<title>grade1</title>
</head>
<body>
<form action=insertattend.php method=POST>
<table border="1" cellspacing="1" cellpadding="1" width="200" height="200">
<tr>
<th>classid</th>
<th>studentid</th>
<th>teacherid</th>
<th>locid</th>
<th>date</th>
<th>flag</th>
<th>comments</th>
</tr>
<?php
include 'conn.php';
$query = "(SELECT a.classid, a.fname, b.teacherid, c.locid
FROM class_master c JOIN student_master a
ON c.classid = a.classid JOIN teacher_link b
ON c.classid = b.classid
WHERE c.classid = 'grade1' )";
$result = mysql_query($query);
$i=1;
while( $row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . "<input name=classid[] type=text value=" .$row['classid']." </td>";
echo "<td>" . "<input name=fname[] type=text value=" .$row['fname']." </td>";
echo "<td>" . "<input name=teacherid[] type=number value="
.$row['teacherid']." </td>";
echo "<td>" . "<input type=number name=locid[] value=" .$row['locid']." </td>";
echo "<td>" . "<input name=date[] type=date value='date'></td>";
echo "<td>" . "<input type=radio id=attend name=attend[] value='present'>";?>P
<?php echo "<input type=radio id=attend name=attend[] value='absent'>";?>A
<?php
echo"</td>";
echo "<td><input name=comment[] type=text row=3 column=5></td>";
echo "</tr>";
}
?>
</table>
<input type="submit" value="submit">
</form>
</body>
</html>
And in php page you take size of any of the coming array
For eg:sizeof(classid);using that write for loop to accept values

Adding dropdown list with the values being populated from database

I'm trying to create a dropdown list with the values being populated from the database. In the following code, I have created a table for viewing the student details and created delete and add buttons to add and delete the information.
The problem is while adding the details for class id, I used a dropdown value from another table to be populate the values, but I was not able to do it.
<html>
<head><title>viewstudent</title>
<?php
$host = "localhost";
$user = "root";
$pass = "";
$dbname = "my_attendance";
$prefix = "";
$con = mysql_connect($host, $user, $pass)
or die ("not connected to db");
mysql_select_db($dbname, $con)
or die("database not selected");
if (isset($_POST['delete'])){
$deleteqry = "DELETE from student_master WHERE ID='$_POST[hidden]'" ;
mysql_query($deleteqry, $con);
};
if (isset($_POST['add'])){
$clid=mysql_real_escape_string($_POST['classid']);
$sid=mysql_real_escape_string($_POST['studentid']);
$fn=mysql_real_escape_string($_POST['fname']);
$ln=mysql_real_escape_string($_POST['lname']);
$dob=mysql_real_escape_string($_POST['dob']);
$em=mysql_real_escape_string($_POST['email']);
$ph=mysql_real_escape_string($_POST['phone']);
$loc=mysql_real_escape_string($_POST['locationid']);
$emer=mysql_real_escape_string($_POST['emergency']);
$addquery = ("INSERT INTO student_master(classid, studentid, fname, lname, dob, phone, email, locationid, emergency)
VALUES('$clid', '$sid', '$fn', '$ln', '$dob', '$ph', '$em', '$loc', '$emer')");
mysql_query($addquery, $con);
};
$query=("SELECT * FROM student_master");
$result = mysql_query($query);
?>
</head>
<body>
<table align="center" width="500" border="1" cellspacing="1" cellpadding="1">
<tr>
<th>Id</th><th>classid</th><th>studentid</th><th>fname</th><th>lname</th><th>dob</th><th>phone</th><th>email</th><th>locationid</th><th>emergency</th>
</tr>
<?php
while( $row = mysql_fetch_array($result,MYSQLI_ASSOC))
{
echo "<form action=viewstudentinfo.php method=POST >";
echo "<tr align='center'>";
echo "<td>" . "<input type=text name=ids value=" .$row['id']." </td>";
echo "<td>" . "<input type=text name=classid value=" .$row['classid']." </td>";
echo "<td>" . "<input type=number name=studentid value=" .$row['studentid']." </td>";
echo "<td>" . "<input type=text name=fname value=" .$row['fname']." </td>";
echo "<td>" . "<input type=text name=lname value=" .$row['lname']." </td>";
echo "<td>" . "<input type=text name=dob value=" .$row['dob']." </td>";
echo "<td>" . "<input type=text name=phone value=" .$row['phone']." </td>";
echo "<td>" . "<input type=text name=email value=" .$row['email']." </td>";
echo "<td>" . "<input type=text name=locationid value=" .$row['locationid']." </td>";
echo "<td>" . "<input type=text name=emergency value=" .$row['emergency']." </td>";
echo "<td>" . "<input type=hidden name=hidden value=" .$row['id']." </td>";
echo "<td>" . "<input type=submit name=delete value=Delete" ." </td>";
echo "</tr>";
echo "</form>";
}
echo "<form action=viewstudentinfo.php method= post>";
echo "<tr>";
echo "<td><input type=text name=id></td>";
echo "<td><select type=text name=classid></td>";?>
// populating classid values from another table....
<?php
$query = 'SELECT classid FROM class_master';
$result1 = mysql_query($query, $con) or die(mysql_error($con));
while ($row = mysql_fetch_array($result1))
{
echo '<option value="' . $row["classid"] . '"> ' . $row["classid"] . '</option>';
}
echo "</select>";
?>
<?php
echo "<td><input type=number name=studentid></td>";
echo "<td><input type=text name=fname></td>";
echo "<td><input type=text name=lname></td>";
echo "<td><input type=date name=dob></td>";
echo "<td><input type=number name=phone></td>";
echo "<td><input type=email name=email></td>";
echo "<td><input type=number name=locationid></td>";
echo "<td><input type=number name=emergency></td>";
echo "<td>" . "<input type=submit name=add value=ADD" ." </td>";
echo "</tr>";
echo "</form>";
echo "</table>";
mysql_close($con);
?>
You are closing the <td> inside the select:
Replace
echo "<td><select type=text name=classid></td>";?>
With
echo "<td><select type=text name=classid>";?>
And close the '</td>' after the '</select>'
Find out <td><select type=text name=classid></td> in your code and remove the ending tag </td> from it. After all the <option> ... </option> close the </td>

How to make sure all content appear on the cell and not just the first word?

I am having a problem displaying content on a table from mysql table in the database to a form in PHP. My problem is that only the first word show on the address field for example.
Please look at my page on: http://www3.londonmet.ac.uk:8008/~iia0014/employeeManager.php
And also the cells are not aligned with the title.
Can anyone help me to solve this?
On my css I have:
table {
table-layout:fixed;
width:180%;
overflow:hidden;
border:1px ;
word-wrap:nowrap;
text-align:left;
}
But even if removing the CSS, just the first word appear.
PHP CODE:
<?php
// Connect to server and select databse.
$con = mysql_connect("$host","$username","$password");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("$db_name",$con);
if(isset($_POST['update'])){
$UpdateQuery = "UPDATE employees SET
Name='$_POST[name]',
DOB='$_POST[dob]',
Tel='$_POST[tel]',
Address='$_POST[address]',
Department='$_POST[department]',
PayRate='$_POST[payrate]',
Skills='$_POST[skills]',
Gender='$_POST[gender]'
WHERE EmpNo='$_POST[hidden]'";
mysql_query($UpdateQuery, $con);
};
if(isset($_POST['delete'])){
$DeleteQuery = "DELETE FROM employees WHERE EmpNo='$_POST[hidden]'";
mysql_query($DeleteQuery, $con);
};
if(isset($_POST['add'])){
$AddQuery = "INSERT INTO employees (EmpNo, Name, DOB, Tel, Address, Department, PayRate, Skills, Gender) VALUES ('$_POST[uempNo]','$_POST
[uname]','$_POST[udob]', '$_POST[utel]','$_POST[uaddress]','$_POST[udepartment]', '$_POST[upayrate]','$_POST[uskills]','$_POST[ugender]')";
mysql_query($AddQuery, $con);
};
$sql = "SELECT * FROM employees";
$myData = mysql_query($sql,$con);
?>
<table border="1" width="10%">
<?php
echo "<tr>
<th>Number</th>
<th >Employee Name</th>
<th>DOB</th>
<th>Telephone</th>
<th>Address</th>
<th>Department</th>
<th>Pay Rate</th>
<th>Skills</th>
<th>Gender</th>
</tr>";
while($record = mysql_fetch_array($myData)){
echo "<form action=employeeManager.php method=post>";
echo "<tr>";
echo "<td>" . "<input type=hidden name=hidden value=" . $record['EmpNo'] . " </td>";
echo "<td>" . "<input type=text name=name value=" . $record['Name'] . " </td>";
echo "<td>" . "<input type=text name=dob value=" . $record['DOB'] . " </td>";
echo "<td>" . "<input type=text name=tel value=" . $record['Tel'] . " </td>";
echo "<td>" . "<input type=text name=address value=" . $record['Address'] . " </td>";
echo "<td>" . "<input type=text name=department value=" . $record['Department'] . " </td>";
echo "<td>" . "<input type=text name=payrate value=" . $record['PayRate'] . " </td>";
echo "<td>" . "<input type=text name=skills value=" . $record['Skills'] . " </td>";
echo "<td>" . "<input type=text name=gender value=" . $record['Gender'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "<td>" . "<input type=submit name=delete value=delete" . " </td>";
echo "</tr>";
echo "</form>";
}
echo "<form action=employeeManager.php method=post>";
echo "<tr>";
echo "<td><input type=text name=uempNo></td>";
echo "<td><input type=text name=uname></td>";
echo "<td><input type=text name=udob></td>";
echo "<td><input type=text name=utel></td>";
echo "<td><input type=text name=uaddress></td>";
echo "<td><input type=text name=udepartment></td>";
echo "<td><input type=text name=upayrate></td>";
echo "<td><input type=text name=uskills></td>";
echo "<td><input type=text name=ugender></td>";
echo "<td>" . "<input type=submit name=add value=add" . " </td></tr>";
echo "</form>";
echo "</table>";
mysql_close($con);
?>
In the below quotes you were missing quotes and the tags were not closed proprely!
while($record = mysql_fetch_array($myData)){
echo "<form action='employeeManager.php' method='post'>";
echo "<tr>";
echo "<td><input type='hidden' name=hidden value='" . $record['EmpNo'] . "'> </td>";
echo "<td><input type='text' name='name' value='" . $record['Name'] . "'> </td>";
echo "<td><input type='text' name='dob' value='" . $record['DOB'] . "'> </td>";
echo "<td><input type='text' name='tel' value='" . $record['Tel'] . "'> </td>";
echo "<td><input type='text' name='address' value='" . $record['Address'] . "'> </td>";
echo "<td><input type='text' name='department' value='" . $record['Department'] . " </td>";
echo "<td><input type='text' name='payrate' value='" . $record['PayRate'] . "'> </td>";
echo "<td><input type='text' name='skills' value='" . $record['Skills'] . "'> </td>";
echo "<td><input type='text' name='gender' value='" . $record['Gender'] . "'> </td>";
echo "<td><input type='submit' name='update' value='update'> </td>";
echo "<td><input type='submit' name='delete' value='delete'> </td>";
echo "</tr>";
echo "</form>";
}
For better understanding of your mistake, notice your code:
echo "<td><input type=text></td>";
It should be like that:
echo "<td><input type='text'></td>";
It works, its just that you don't close the tag, which results in:
<input type=text name=address value=one two thre
The browser reads it as value=one and "two" and "three" like separate arguments.
What you need is a quote like this:
<input type=text name=address value="one two three"/>

Reading 0 and 1 from a database and retrieving in a checkbox

I am trying to create a members table, using a PHPmyadmin database, and in the database, there is a 0 & 1 field, and I want to transform the 0 and 1 in a checkbox, for each member. Is an editable table, so the table might be in a form. Here is what I did:
<?php
include('../../config.php');
$result2 = mysql_query("SELECT * FROM acars_users");
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Dados Pessoais</th>
<th>Origem</th>
<th>Dados de Redes</th>
<th width='220px'>Base</th>
<th>Patente</th>
<th>Horas</th>
<th>É Ativo?</th>
<th>Dinheiro</th>
<th>Senha</th>
<th>Opções</th>
</tr>";
while($row = mysql_fetch_array($result2))
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td width='300px'>" . "<form action=editar.php method=POST><input name=username size=7 type=text value=".$row['username']." /></br><input name=nome size=10 type=text value=".$row['nome']." /><input name=sobrenome size=20 type=text value=".$row['sobrenome']." /></br><input name=email size=25 type=text value=".$row['email']." />" . "</td>";
echo "<td>" . "<input name=datanascimento size=10 type=text value=".$row['datanascimento']." /></br><input name=pais size=10 type=text value=".$row['pais']." /></br><input name=cidade size=30 type=text value=".$row['cidade']." />" . "</td>";
echo "<td>" . "IVAO: <input name=idivao size=8 type=text value=".$row['idivao']." /></br>VATSIM: <input name=idvatsim size=8 type=text value=".$row['idvatsim']." />" . "</td>";
echo "<td>" . "<input name=base size=8 type=text value=".$row['base']." />" . "</td>";
echo "<td>" . "<input name=rank size=10 type=text value=".$row['rank']." /></br>Admin <input name=admin size=1 type=checkbox value=".$row['admin']." /></br>DOV <input name=dov size=1 type=checkbox value=".$row['dov']." /></br>Checador <input name=checador size=1 type=checkbox value=".$row['checador']." />" . "</td>";
echo "<td>" . "<input name=horas size=6 type=text value=".$row['horas']." />" . "</td>";
echo "<td>" . "<input type=checkbox name='isactive[]' value=".$row['isactive']." />" . "</td>";
echo "<td>" . "<input name=dinheiro size=10 type=text value=".$row['dinheiro']." />" . "</td>";
echo "<td>" . "<input name=password size=10 type=password value=".$row['password']." />" . "</td>";
echo "<td>" . "<input name=edit_id value=".$row['id']." type=hidden><input type=submit value=Editar ></form><form action=deletarexist.php method=POST><input name=delete_id value=".$row['id']." type=hidden><input type=submit value=Demitir></form>" . "</td>";
echo "</tr>";
}
echo "</table>";
?>
$chkd=$row['isactive']?'checked="checked"':''; // 0: false; 1: true
echo "<td><input type='checkbox' name='isactive[]' value='{$row['isactive']}' $chkd></td>";
(Although, you should look into using a templatingg system (such as smarty) rather than echoing html fragments. It seems at bit weird in the start, but as soon as you get used to it, you'll never look back-)
I guess you want the checkbox checked, and in that case you need to add the checked="checked" attribute to the checkbox.
So what you would do would be something like this:
if($row['isactive'] == 1){
echo "<td>" . "<input type='checkbox' name='isactive[]' value=".$row['isactive']. checked='checked' />" . "</td>";
} else {
echo "<td>" . "<input type='checkbox' name='isactive[]' value=".$row['isactive']." />" . "</td>";
}
For the value you probably should have something to identify the checkbox, like a memberid depending on what you are using it for.

Categories