Forum Moderators: coopster
What he wants this database to do is keep track of payment amount, payment due dates, payment collection, contact info.
My current plan for the database side is have one the following tables:
Locations:
ID*, Name, Address, ManagerName, etc
Rental:
ID*, Room #, tenants.period (monthly or weekly), tenants.cost, location.ID, etc.
Tenants:
rental.ID, First, Last, Phone, period, cost, etc
ID* is the unique ID. The idea I have is to have the tenants table be separate from the Rental table so you don't ever have to modify the rental table. Does my layout appear to be sound? Does MySQL work this way? What am I overlooking?
OK. The actual question about PHP:
If I want to add a location using forms, do I need to have an addlocation.php that has a form action leading to locationadded.php? Do I have to do that for each table, or is there a better way?
My current php structure is like so:
<form action="locationadded.php" method="post">
Name: <input type="text" name="name"><br>
Street Address: <input type="text" name="address"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
ZIP: <input type="text" name="zip"><br>
Manager: <input type="text" name="manager"><br>
Phone: <input type="text" name="phone"><br>
<input type="Submit">
</form>
This will run locationadded.php, which would insert the values into the database. This seems really rudimentary.
Firstly i suppose it depends what you mean by "I have no experience with PHP." If that means you can't actually code PHP then I think you may struggle. If you can, and like me you class say a few DB driven sites as still fairly inexperienced you may be ok. If you don't know PHP and/or MySQL I would recommend you read PHP and MySQL For Dynamic Websites by Larry Ullman as I think that should soon set you on your way.
As for inserting into the database, you could do it one of two ways. You could have addlocation.php displaying the form and then POST the values to locationadded.php and let this handle the form and enter the data into the DB. Alternatively you could use addlocation.php to display the form, and then POST the values to itself, and use an if(isset ($_POST['submit'])) to check whether the form is submitted, and thus whether to handle it and insert into the DB or whether to display the form.
[edit] What theriddla1019 was saying was the former of those two methods. I personally use the latter on most occasions but that is just personal preference as he/she said.
Hope this helps
Cheers
Richard
I was posting this to make sure that there weren't any glaring flaws in my reasoning that a book wouldn't catch.
Thanks,
Nathan