Things to do
"; $host="localhost"; $user="things"; $password="PASSWORD"; $cxn = mysqli_connect($host,$user,$password); if (!empty($_POST['checkbox'])) { $sql1 = "UPDATE things.items set isVisible=0 where iditems=".$_POST['checkbox']; $result = mysqli_query($cxn,$sql1); if($result == false) { echo "error updating table"; } } if (!empty($_POST['retr'])) { $sql2 = 'select iditems,content,isVisible from things.items where iditems='.$_POST['retr']; $result = mysqli_query($cxn,$sql2); if($result == false) { echo "error retrieving data.
Refresh
"; } else { echo "
"; echo "
ID
Content
isVisible
"; for($i = 0; $i < mysqli_num_rows($result); $i++) { $row_array = mysqli_fetch_row($result); echo "
"; for($j = 0;$j < mysqli_num_fields($result);$j++) { echo "
".$row_array[$j]."
\n"; } echo "
"; } echo "
Back
"; } } if (!empty($_POST['newcontent'])) { $sql3 = "INSERT INTO things.items (content, isVisible) VALUES ('".$_POST['newcontent']."', 1)"; $result = mysqli_query($cxn,$sql3); if($result == false) { echo "Could not add new todo"; } } if (!empty($_POST['list'])) { $sql4 = "SELECT * from things.items"; $result = mysqli_query($cxn,$sql4); if($result == false) { echo "Could not list all items.
Back
"; } else { echo "
"; echo "
ID
Content
isVisible
"; for($i = 0; $i < mysqli_num_rows($result); $i++) { $row_array = mysqli_fetch_row($result); echo "
"; for($j = 0;$j < mysqli_num_fields($result);$j++) { echo "
".$row_array[$j]."
\n"; } echo "
"; } echo "
Back
"; } } if (empty($_POST['retr'])) { if (empty($_POST['list'])) { $sql="select iditems,content from things.items where isVisible = 1;"; $result = mysqli_query($cxn,$sql); if($result == false) { echo "
Error: ".mysqli_error($cxn)."
"; } else { /* Table that displays the results */ echo "
"; for($i = 0; $i < mysqli_num_rows($result); $i++) { echo "
"; $row_array = mysqli_fetch_row($result); for($j = 1;$j < mysqli_num_fields($result);$j++) { echo "
".$row_array[$j]."
\n"; } } echo "
Retrieve:
New: