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

 

Link to comment
Share on other sites

Ok I've fixed it I'm not sure it's the best way to do it but I've included the div in the echo statement and it seems to be working fine, I was just having a problem with quotations in the html code within the echo command!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.