from the title, you can probably tell i'm an amateur. However, i would like to create a form for my MySQL/ php site, which requires fields from different tables throughout my DB. Is this possible? or do i need to create a table with all the neccessary fields in it?
Also, isit possible to save the output of this form and view all the outputs upon requested?
Thanks in advance.
ask any questions if i left anything out. I kept it short as I think this may be a simple question :@!
really appreciate it.
Yes you can! PHP use the function echo
to print data to the HTML page. this mean that you can read from the DB first and using IF
to print different HTML form.
for example(Pseudo Code):
$in=getFrom(DB);
if($in['key']=="value")
{
echo ".....specific HTML....... ";
}
else
{
echo ".....alternative HTML....... ";
}
I am not sure i understood your question correctly but..
If you want to combine data from different tables you want to perform a database query with a JOIN
for example, if you have one table with people and one table with their pets you can combine this data in the same output by writing :
select * from persons
left outer join pets on (pets.person_id = persons.id)
Now, if you want to "save this output" you should create a VIEW
create view persons_and_their_pets as
(
select * from persons
left outer join pets on (pets.person_id = persons.id)
)
you are now able to access this data via:
select * from persons_and_their_pets