Haven’t touched php out for years, trying to help a friend out and struggling!
He already has php/sql running for other things so this seemed the right route to follow.
The idea is to be able to track deposits.
Atm I’ve set the database up and created a html entry form leading to php script
[php]<?php
$con=mysqli_connect(“localhost”,“depo”,“depo”,“deposits”);
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$name = mysqli_real_escape_string($con, $_POST[‘name’]);
$unit = mysqli_real_escape_string($con, $_POST[‘unit’]);
$item = mysqli_real_escape_string($con, $_POST[‘item’]);
$depo = mysqli_real_escape_string($con, $_POST[‘depo’]);
$odate = mysqli_real_escape_string($con, $_POST[‘odate’]);
$rdate = mysqli_real_escape_string($con, $_POST[‘rdate’]);
$sql=“INSERT INTO depos (name, accom, item, deposit, odate, turn, rdate)
VALUES (’$name’, ‘$unit’, ‘$item’, ‘$depo’, ‘$odate’, ‘no’, ‘$rdate’)”;
if (!mysqli_query($con,$sql)) {
die('Error: ’ . mysqli_error($con));
}
echo “1 record added”;
mysqli_close($con);
?>[/php]
I’m struggling with my next stages which would be.
-
showing the ID after entry (col 1,‘ID’, mediumint(9) , AUTO_INCREMENT) been playing with mysql_insert_id but can’t seem to get it right
-
opening up and editing entrys, either by ID number or viewing list
-
using SUM to calculate value of all under deposit only IF turn = ‘no’
Any help muchly appreciated!
Cheers, Rory