
jamjam
Members-
Posts
32 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
jamjam's Achievements

Newbie (1/5)
0
Reputation
-
Hi This is really driving me crazy, so please help. I have this code as shown below, it displays a list of dates for the next 7 days. Things i want the code achieve. 1. Display "Today and "Tomorrow" instead of the corresponding date. 2. Once a date is selected add "current" class, this way it is highlighted with a different color. 3. "Today" should be selected by default when the page is first loaded. The code below achieve this requirements <?php $today = date("d-m-Y", strtotime('today')); $tomorrow = date("d-m-Y", strtotime('tomorrow')); echo ' <li><a href="?date='.$today.'">'.(($_GET['date'] == $today) ? '<span class="current"' . '>Today</span>' : 'Today').'</a></li>'; echo ' <li><a href="?date='.$tomorrow.'">'.(($_GET['date'] == $tomorrow) ? '<span class="current"' . '>Tomorrow</span>' : 'Tomorrow').'</a></li>'; for ($time = strtotime('+2 days'), $i=0; $i < 5; $time = strtotime('+1 days', $time), $i++) {$date = date("d-m-Y", $time); echo ' <li><a href="?date='.$date.'">'.(($_GET['date'] == $date) ? '<span class="current">' : '') . date("D jS", $time) . ((isset($_GET['date']) && $_GET['date'] == $date) ? '</span>' : '') . "</a></li>";} ?> However recently i needed to change the formating of the date from d-m-Y to Y-m-d As result of this my third requirement the one about "Today" been selected by default no longer works. <?php $today = date("Y-m-d", strtotime('today')); $tomorrow = date("Y-m-d", strtotime('tomorrow')); echo ' <li><a href="?date='.$today.'">'.(($_GET['date'] == $today) ? '<span class="current"' . '>Today</span>' : 'Today').'</a></li>'; echo ' <li><a href="?date='.$tomorrow.'">'.(($_GET['date'] == $tomorrow) ? '<span class="current"' . '>Tomorrow</span>' : 'Tomorrow').'</a></li>'; for ($time = strtotime('+2 days'), $i=0; $i < 5; $time = strtotime('+1 days', $time), $i++) {$date = date("Y-m-d", $time); echo ' <li><a href="?date='.$date.'">'.(($_GET['date'] == $date) ? '<span class="current">' : '') . date("D jS", $time) . ((isset($_GET['date']) && $_GET['date'] == $date) ? '</span>' : '') . "</a></li>";} ?> Can someone please help with this. Thanks in advance
-
Hi I am complete javascrpt newbie, I have this script. Not my work. function fav() { var newT = document.createTextNode('Add to Favourites'); var s = document.getElementById('fav'); if (window.sidebar) { s.appendChild(newT); s.style.cursor = 'pointer'; s.onclick = function() {window.sidebar.addPanel(document.title,self.location,'')}; } else if (window.external) { s.appendChild(newT); s.style.cursor = 'pointer'; s.onclick = function() {window.external.AddFavorite(self.location,document.title)}; } else if (window.opera) { s.appendChild(newT); s.style.cursor = 'pointer'; s.onclick = function() { var e = document.createElement('a'); e.setAttribute('href',self.location); e.setAttribute('title',document.title); e.setAttribute('rel','sidebar'); e.click(); } } } var pageLoaded = 0; window.onload = function() {pageLoaded = 1;} function loaded(i,f) { if (document.getElementById && document.getElementById(i) != null) f(); else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100); } loaded('fav',fav); The script adds a add to favourites link to a page. This works without any problems. My intention is to adapt the script so instead of outputting a link(text) it outputs a image. But I don't how to do this. Please help. Thanks
-
I worked it out It seems there was conflicting class as when I added "email" nothing was showing up. Chooosing a different class solved the problem.
-
Hi This is very silly question, but can someone please tell what is wrong. I have a small piece of javascript code Here it is. google.load("jquery", "1.3.1"); jQuery.fn.fadeToggle = function(speed, easing, callback) { return this.animate({opacity: 'toggle'}, speed, easing, callback); }; $(document).ready(function() { $('#tellfriend').hide(); $('li a.email, #tellfriend a.close').click(function() { $("#tellfriend").fadeToggle('slow'); }); }); Once a email icon button is clicked this code fades in a email form. The associated html looks like this <li><a class="email" href="#tellafreiend" alt="Email" id="emails">Email</a></li> This all works. But I need to change the associated html to something like this <li><a href="#tellafreiend" alt="Email"><img src="/files/email.png" alt="Email"/></a></li> However once I do this the fade in effect no longer works and I do not see the email form. I know the problem is properly a result of incorrect class or id. But I cannot fix it. Thanks.
-
YES Finally it worked. However the HTML formatting got lost along the way. So have to figure that out now. Thanks for all your help guys.
-
YES Finally this works. But the my original HTML formatting has been lost. So I have to figure how to but this back. Thanks for all your help guys.
-
Hi Pikachu2000 When I tried your solution I got this error Notice: Undefined variable: totalRows in F:\wamp\www\includes\info\credits.php on line 6 I think I fixed by changing totalRows to totalRows_director Having done this, I get blank results with this code. Even though the director field contains at least 2 rows of data.
-
Hi litebearer I tried your solution but there seems to be syntax errors. I replace the double quotes with single quotes and that did reduce the error but there is at lease one syntax error I am unable to fix. Please double check Thanks
-
That's what I am trying to do but I don't how to. Can you show me how achieve this?
-
If your referend to the database connection etc litebearer here it is mysql_select_db($database_main, $main); $query_director = "SELECT information.title, director FROM information INNER JOIN director ON information.title = director.title"; $director = mysql_query($query_director, $main) or die(mysql_error()); $row_director = mysql_fetch_assoc($director); $totalRows_director = mysql_num_rows($director); HTML <?php if($row_director['director'] == "") {echo "";} else {echo " <table> <th> <h4>Directed by</h4> </th> <td> <h5> $row_director['director'] </h5> <br /> </td> </table> <br /> ";}?> I can echo all results contained in the $director['director'] quite easily, the problem is that I want place these results inside an if else statment. This way if $director['director'] is empty then the html is not displayed. Hope that makes sense
-
Hello Thanks for the quick reply. Your solution looks good but it don't work. I want to echo all the results in {$row_director['director']}. But this is only one result showing in the browser. The database table contains two rows and I wanted to output both to show the while is working. Thanks again
-
I want to control the output of php code with if else statement like this. <?php if($row_director['director'] == "") {echo "";} else {echo " <table> <th> <h4>Directed by</h4> </th> <td> <h5> $row_director['director'] </h5> <br /> </td> </table> <br /> ";}?> I also want to loop through the results contained in $row_director['director'] Having tried various ways to achieve this, I have now given up. Can someone please help me.
-
Thanks Matthew It worked perfectly.
-
Hi I am developing a page that has this PHP code <?php echo $row_Programme['status']; ?> This code basically looks in a MySQL database table and echo’s the value of the status field. The value of the Status field will only ever have 5 possible values. I want to add an ‘if statement’ to the above code. So for example if the value returned by the code was “Coming Soon” I can add something like “Programme will be available soon” A second example would be if the value returned by the code was “Not Available” I can add something like “Sorry programme is not available” This properly really basic PHP. But am really new to this and will really appreciate the assistance. Thanks in advance.
-
Any one? Please help me.