"; echo ""; } } ?>

My Bills

MySQL Error - Cannot delete from table: ".mysql_error()); echo("
SQL Statement: ".$query); } //Loop through table and insert values into the database while (true) { $item_name = 'item'."$write_ctr"; $item_value = $_POST[$item_name]; $amount_name = 'amount'."$write_ctr"; $amount_value = $_POST[$amount_name]; if (empty($amount_value)) { break; } //validate amounts before inserting //$amount_value = trim($amount_value); if (!is_numeric(trim($amount_value))){ //$error_cnt++; //adds 1 to $error_cnt print "Item '$item_value' has amount '$amount_value' which is not a number."; break; } else { //Insert an item to the table $query = "INSERT INTO barr_alan_144_expenses (item, amount) VALUES ('$item_value', '$amount_value')"; $result = mysql_query($query); if (mysql_error()) { echo("
MySQL Error - Cannot insert a row into table ".mysql_error()); echo("
SQL Statement: ".$query); } $write_ctr++; } } //} //************************************************* //Now Select from table and Display //************************************************* $read_ctr = 1; $query = "SELECT item, amount FROM barr_alan_144_expenses"; $result = mysql_query($query); if (mysql_error()) { echo("
MySQL Error- Cannot select from table: ".mysql_error()); echo("
SQL Statement: ".$query); } if (!empty($result)) { $numresults = mysql_num_rows($result); if ($numresults > 0) { for ($read_ctr = 1; $read_ctr <= $numresults; $read_ctr++) { $row = mysql_fetch_array($result); $item_value = $row['item']; $amount_value = $row['amount']; $item_name = 'item'."$read_ctr"; $amount_name = 'amount'."$read_ctr"; print ''; print "\n"; print "\n"; print "'; } } } //************************************************* //Now write the blank lines //************************************************* for ($i = $read_ctr; $i < $read_ctr + 2; $i++) { $item_name = 'item'."$i"; $amount_name = 'amount'."$i"; print ''; print "\n"; print "\n"; print ''; } ?>
Item Amount
"; print '
"; } ?>