Jump to content

[SOLVED] This is extremely tricky and hard to explain..


Recommended Posts

I need to output/echo a url depending on a combination of three variables.  I have three variables: category, subcategory, and post.  There is a different category each day of the week (assigned 1 through 7), there are 5 subcategories for each category (assigned 1-5) and there are 10 actual posts in each category->subcategory.

 

I've created a variable for each combination of cat-subcat-post and given it the value of that particular post's url.  So for example, if I have a post in the category "PC" and the subcategory "Battlefield 1942" and under the post for "Gameplay" then my variable looks like this:  $link142 = 'http://wwwdotthelinkdotcom';  This is because PC would be assigned as category 1, BF1942 would be assigned #4 on the list of PC games (subcategory) and gameplay would be assigned as the second post for all games.

 

The links that I would like to display change automatically depending on the day/month and look random.  If i try to output link.php?url=<?php $link1 = 'link' . $cat . $subcat . $post; echo $link1; ?> it will link the image to link.php?url=link142, and not to the actual url that $link142 is defined as.  What I need to do is figure out some way of putting together the right variable to output, but the only way I can think of is using the 'echo $variable' inside of the other echo.  Like link.php?url=<?php echo $link<?php echo $cat . $subcat . $post; ?>; ?>

 

That obviously doesn't work, but the only other way I can possibly see this working is by making a switch for each day of the week with 50 cases each. That would be 350 switches, and I need to have several of these on the page. I didn't think that having 1500 switch cases on every page load would be a very good idea.

 

If anyone even understands what I am trying to explain/do, I would greatly appreciate some help from real programmers that know what they're doing.

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.