spratap2312 Posted June 14, 2017 Share Posted June 14, 2017 HI , I have below php code in which the month is hardcoded , how can i pass current month to it. <?php echo "<li style=\"display: list-item;\" ><a href=\"#\"></a> <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=02&SITE=WWDC\">WWDC</a></li> <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=02&SITE=NOIDA\">Noida</a></li> <li style=\"display: list-item;\" ><a href=\"#\"></a></li>"; ?> Quote Link to comment Share on other sites More sharing options...
requinix Posted June 14, 2017 Share Posted June 14, 2017 Take a look at the date function. Quote Link to comment Share on other sites More sharing options...
spratap2312 Posted June 14, 2017 Author Share Posted June 14, 2017 HI , I passed the parameter as below <?php echo "<li style=\"display: list-item;\" ><a href=\"#\"></a> <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=date(m)&SITE=WWDC\">WWDC</a></li> <li style=\"display: list-item;\" ><a href=\"http://mis.sgp.st.com/OVO_Alerts.php?MONTH=date(m)&SITE=NOIDA\">Noida</a></li> <li style=\"display: list-item;\" ><a href=\"#\"></a></li>"; ?> but it is giving error when the target php is getting called what should be the syntax of it. Quote Link to comment Share on other sites More sharing options...
requinix Posted June 14, 2017 Share Posted June 14, 2017 Are you remotely familiar with PHP? Do you know how to write and use it? Have you used variables and functions before? Quote Link to comment Share on other sites More sharing options...
spratap2312 Posted June 14, 2017 Author Share Posted June 14, 2017 I am new to it but i have just studied basics of it from w3schools , i am using a existing website and trying to modify it. Quote Link to comment Share on other sites More sharing options...
benanamen Posted June 14, 2017 Share Posted June 14, 2017 Once you get that figured out, use single quotes on your elements and get rid of that clustermuck of quote escaping. Stay away from echoing what is almost all pure HTML. Use the output tag. <= $some_variable ?> 1 Quote Link to comment Share on other sites More sharing options...
requinix Posted June 14, 2017 Share Posted June 14, 2017 If what you posted really is what you're working with, meaning that the echo is the only bit of code you have between those <?php ?> tags, then wouldn't you agree that <?php $month = date("m"); ?> <li style="display: list-item;" ><a href="#"></a> <li style="display: list-item;" ><a href="http://mis.sgp.st.com/OVO_Alerts.php?MONTH=<?=$month?>&SITE=WWDC">WWDC</a></li> <li style="display: list-item;" ><a href="http://mis.sgp.st.com/OVO_Alerts.php?MONTH=<?=$month?>&SITE=NOIDA">Noida</a></li> <li style="display: list-item;" ><a href="#"></a></li> is much easier to look at? You're also missing a on that first link, though I don't believe it's technically required. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.