Jump to content

Control Visible Page Content via DB Entries?!


ccmcs

Recommended Posts

Hi, I've done some serious google'ing... I'm all googled out and it doesn't appear there is a solution to this the way I'm attempting it and it's probably more a case of my early ventures into development that I'm missing something that may or may not be a better and if not more obvious way to do this...

 

Here's the principle, Customer Logs into webpage - greeted by profile page (all cushty so far) - Can choose to move to view 'audio files' which relate to the products they have purchased (this is where it gets silly...)

 

The idea is that both the profile page and the audio page are controlled by a $_SESSION within PHP scripting so the pages are dynamic.  I want to include all of the audio files for every product on the 'audio.php' page BUT I only want the ones that they have purchased to be visible...

 

All the setup is fine because the following works fine:

if($info['halftimerock'] == 1) { echo "<p>Half Time Rock</p>";}

 

Which essentially checks the db, finds a 1 in the appropriate product and displays the name of the product in a list, if no products then nothing in the list etc.

 

What I want to do is control the visibility of some <div>'s using the same kind of idea, so:

if($info['halftimerock'] == 1) { CODE TO DISPLAY DIV IN HERE }

 

I have a 'toggleelement' JS function available which works for mouse clicks but obviously php and js don't exactly go well together so that is probably not the way to go, I'm already running a lot of PHP at the top of the page before the HTML to stop session header errors.

 

A couple of web searches have suggested I insert a <script> tag into the echo command but I can't get that to work and I guess it's a really messy way of trying to do things!

 

So here's the question, any ideas about how to toggle <div> visibility within php or is that purely something for js to handle?...

Is there a better/cleaner way of doing it all, perhaps redirecting users to different pages based on their entries in the DB (which could all be handled with headers but I'll end up with a million different pages and combinations eventually?

 

I could always create a .htaccess/.htpasswd file system and handle the folders with audio content in manually so that all files are visible but only a valid username and password will be able to access the file but that's going to get annoying for people having to put in user/pass for every file and also for me updating the users for each individual file every time some1 buys something...

 

Any ideas?  Anybody done anything similar?  Cheers

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.