fender967 Posted February 17, 2009 Share Posted February 17, 2009 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. Link to comment https://forums.phpfreaks.com/topic/145567-solved-this-is-extremely-tricky-and-hard-to-explain/ Share on other sites More sharing options...
sasa Posted February 17, 2009 Share Posted February 17, 2009 try link.php?url=<?php $link1 = 'link' . $cat . $subcat . $post; echo $$link1; ?> Link to comment https://forums.phpfreaks.com/topic/145567-solved-this-is-extremely-tricky-and-hard-to-explain/#findComment-764223 Share on other sites More sharing options...
fender967 Posted February 18, 2009 Author Share Posted February 18, 2009 It worked! Thank you so much. Link to comment https://forums.phpfreaks.com/topic/145567-solved-this-is-extremely-tricky-and-hard-to-explain/#findComment-765022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.