Page 1 of 1

Dynamically place object in page using mysql and php?

Posted: Sun Apr 16, 2017 9:31 am
by bburgess
Hi all :)

If this is in the wrong place please move it.

I have been looking for some time for a tutorial or info on using a MySQL database to place objects into a members area I have built with the login tools.

GREAT tools set BTW thanks Pablo :)

Anyway would anybody be able to point me in the right direction please?

Limited knowledge in php but some in MySQL.

Any help very much appreciated!

Cheers
BB

Re: Dynamically place object in page using mysql and php?

Posted: Sun Apr 16, 2017 9:35 am
by [RZ]
do you mean make them visible according to the profile settings or build them dynamically?

Re: Dynamically place object in page using mysql and php?

Posted: Sun Apr 16, 2017 9:51 am
by bburgess
[RZ] wrote: Sun Apr 16, 2017 9:35 am do you mean make them visible according to the profile settings or build them dynamically?
As per the user profile settings mate, I think I should start there. Dynamically may not be the word.

I am still very much learning all this stuff :D

Cheers

Re: Dynamically place object in page using mysql and php?

Posted: Sun Apr 16, 2017 10:01 am
by [RZ]
well, in that case and as you said, you have some basic skills on database, i would start with the simplest way
let's say you have 10 elements in total to be shown them accordingly to the profile
get from the database these setting and assign to php vars, something like:
<?php
$profile_obj_1 = ...
$profile_obj_2 = ...
...etc...
?>

in these vars you may have stored two possible values: 'none' and 'block'
then, assign them to styles (in <head> section)
<style>
#my_obj_1
{
display: <?php $profile_obj_1 ?>;
}
#my_obj_2
{
display: <?php $profile_obj_2 ?>;
}
...etc...
</style>

of course you muse have already created in your html the objects that their names are 'my_obj_1', 'my_obj_2', etc...
i think this is the quickest and simplest way to start...
hope this helps you to begin, just an idea

Re: Dynamically place object in page using mysql and php?

Posted: Sun Apr 16, 2017 10:09 am
by bburgess
RZ thank you very much mate!

That is very helpful! I will have a go and let you know what happens :)

I have everything up in test at the moment so it will be a few days depending on my brain :D

Thank you again!!

Cheers
BB

Re: Dynamically place object in page using mysql and php?

Posted: Sun Apr 16, 2017 10:23 am
by [RZ]
;)

Re: Dynamically place object in page using mysql and php?

Posted: Tue Apr 25, 2017 1:56 am
by bburgess
[RZ] wrote: Sun Apr 16, 2017 10:23 am;)
Hi mate!

I will be comming back to this at some stage, just wanted to say thanks again for your help!

Cheers
BB

Re: Dynamically place object in page using mysql and php?

Posted: Tue Apr 25, 2017 4:23 am
by [RZ]
thank you for your kind words