Jump to content

jamjam

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Everything posted by jamjam

  1. 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
  2. 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
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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
  9. That's what I am trying to do but I don't how to. Can you show me how achieve this?
  10. 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
  11. 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
  12. 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.
  13. Thanks Matthew It worked perfectly.
  14. 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.
  15. Any one? Please help me.
  16. Hi To better explain my problem and hopefully find a solution I have decide to explain the backstory. I am building a database driven website with PHP and MySQL using Dreamweaver CS5. One of the pages on site is called programme, and it access by query string like this www.domain.com/programme/?id=10000000 Depending on the value of the query string, programme data is retrieved from the database and is displayed on the page. All this is working without any problems. In addition to the main programme information, I also want to display related ‘programmes’ on the bottom of the page. To achieve this I have created two ‘record sets’ in Dreamweaver. The first recordset retrieves the main programme and the second recordset will retrieves the related programmes. These are the fields in the database. Id, programme, episode, date, time Recordset 1 : SQL $programme_Programme = "-1"; if (isset($_GET['id'])) { $programme_Programme = $_GET['id']; } mysql_select_db($database_main, $main); $query_Programme = sprintf("SELECT * FROM main WHERE id = %s", GetSQLValueString($programme_Programme, "int")); $Programme = mysql_query($query_Programme, $main) or die(mysql_error()); $row_Programme = mysql_fetch_assoc($Programme); $totalRows_Programme = mysql_num_rows($Programme); I have had great difficulty in the SQL for the second recordsets. I think the solution involves in taking $programme defined in first recodset and using in the second recordset SQL somehow. Something like $related_Related = "-1"; if (isset($_GET['programme'])) { $related_Related = $_GET['programme']; } mysql_select_db($database_main, $main); $query_Related = sprintf("SELECT * FROM main WHERE %s = programme", GetSQLValueString($related_Related, "text")); $Related = mysql_query($query_Related, $main) or die(mysql_error()); $row_Related = mysql_fetch_assoc($Related); $totalRows_Related = mysql_num_rows($Related); But, this does work. I know this is totally messed-up So I would really appreciate if someone can let me know what I should be doing to get this to work. Thanks
  17. YES. I worked it out. I think am genius now. <a href="/day/?date=<?php $date = $_GET['date']; echo $date; ?>">DAY</a> Thanks everyone for all your help!
  18. Thanks for the tips jesirose. I think am making progress. Here is the code in tags </a><br /><br /><table style="text-align: left; width: 553px; height: 11px;" border="0" cellpadding="2" cellspacing="2"><tbody><tr> <?php // set default to 'today' if (!isset($_GET['date'])) $_GET['date'] = date('d-m-Y', time() - 0); // can be a HTML colour code or a literal name, ie: green, red, blue $highlightedColour = '#F54997'; // show today $today = date("d-m-Y", strtotime('today')); echo '<td style="vertical-align: middle;"><big><span style="font-weight: bold;"><a href="?date='.$today.'"'.((isset($_GET['date']) && $_GET['date'] == $today) ? ' style="color:'.$highlightedColour.'"' : '').'>Today </a> </span></big></td>'; // show all the other days for ($time = strtotime('+1 days'), $i=0; $i < 6; $time = strtotime('+1 days', $time), $i++) { $date = date("d-m-Y", $time); echo '<td valign="middle"><big><span style="font-weight: bold;"><a href="?date='.$date.'"'. ((isset($_GET['date']) && $_GET['date'] == $date) ? ' style="color:'.$highlightedColour.'"' : '') .'>' . date("D jS", $time) . "</a></span></big></td>\n"; } ?> <td style="vertical-align: middle; text-align: center;"><big><span style="font-weight: bold;"><span style="color: rgb(245, 73, 151);">EVE </span></big></td><td style="vertical-align: middle; text-align: center; color: rgb(102, 102, 102);"><big><span style="font-weight: bold;">|</span></big></td><td style="vertical-align: middle; text-align: center;"><big><span style="font-weight: bold;"> DAY</span></big></td><td style="vertical-align: middle; text-align: center;"></td></tr></tbody></table> So I have changed the link to the one you suggested. It successful passed the a query string to the 2nd page as I wanted and everything works. But it only passes the date 25-07-2010. I am guessing this is because this the last date on the list. If this can be modified to pass whatever the currently selected date is then I will have found my solution. Thanks
  19. Hi The website I am developing will display TV Listings data. The page I am working on has 7 links to represent days of the week, like this Mon 19th Tue 20th Wed 21st Thu 22nd Fri 23rd Sat 24th Sun 25th Once a linked is clicked this returns schedule for that day. All this is working. My problem is that I wish to separate the data into 2 parts. Prime Time Programming and Day Time Programming. The Prime Time is default so it is automatically displayed when the page is loaded. For the user to see Day Time Programming they must click another link called DAY. This is the link I wish to encode the "current query string" into. So when the user clicks this they will be taking to a second page which uses the value in the current query string. This my code. Please forgive, I don't how to use "tags" </a><br /><br /><table style="text-align: left; width: 553px; height: 11px;" border="0" cellpadding="2" cellspacing="2"><tbody><tr> <?php // set default to 'today' if (!isset($_GET['date'])) $_GET['date'] = date('d-m-Y', time() - 0); // can be a HTML colour code or a literal name, ie: green, red, blue $highlightedColour = '#F54997'; // show today $today = date("d-m-Y", strtotime('today')); echo '<td style="vertical-align: middle;"><big><span style="font-weight: bold;"><a href="?date='.$today.'"'.((isset($_GET['date']) && $_GET['date'] == $today) ? ' style="color:'.$highlightedColour.'"' : '').'>Today </a> </span></big></td>'; // show all the other days for ($time = strtotime('+1 days'), $i=0; $i < 6; $time = strtotime('+1 days', $time), $i++) { $date = date("d-m-Y", $time); echo '<td valign="middle"><big><span style="font-weight: bold;"><a href="?date='.$date.'"'. ((isset($_GET['date']) && $_GET['date'] == $date) ? ' style="color:'.$highlightedColour.'"' : '') .'>' . date("D jS", $time) . "</a></span></big></td>\n"; } ?> <td style="vertical-align: middle; text-align: center;"><big><span style="font-weight: bold;"><span style="color: rgb(245, 73, 151);">EVE </span></big></td><td style="vertical-align: middle; text-align: center; color: rgb(102, 102, 102);"><big><span style="font-weight: bold;">|</span></big></td><td style="vertical-align: middle; text-align: center;"><big><span style="font-weight: bold;"> DAY</span></big></td><td style="vertical-align: middle; text-align: center;"></td></tr></tbody></table> Thanks
  20. Thanks for the explanation jd307 I properly should learn PHP in more detail, but right now I am just after a quick fix to this problem. What would the echo statement look like? Please! On my site the name of the value will always be 'date'. But the value will change everyday for example today it will be 19-07-2010 http://www.mydomain.com/?date=19-07-2010 Thanks
  21. Hi Thanks for the quick reply Ok I have the echo this to page 1 'href="http://www.mydomain.com/something/?"'.$_SERVER['QUERY_STRING']; Once I click it I get echo this in the address bar http://www.mydomain.com/something/? For the second and third solutions I get this in the address http://www.mydomain.com/something/?date= Basically none of them carry the value of the query string from page 1 to page 2. Have I done something wrong? Also otuatail can you please spell out your code so I can copy and paste. This all very new to me. Thanks
  22. Hi I am PHP newbie. I am developing a website with PHP and MYsql. Say this website has two pages, both use query strings to retrieve data from MYsql database. Page 1: http://www.mydomain.com/?value=500 Page 2: http://www.mydomain.com/something/?value=500 I want to echo a link to page 1 so that once it is click it will take the user to page 2, carrying the value of the current query string, something like this. echo href=http://www.mydomain.com/something/$currentquerystring Is this possible? I will appreciate your help. Thanks
  23. Hi This is driving me crazy. Here is my problem. I am developing a webpage that has 7 links, in the content area of the page. The links represent days of the week. Like Mon 12th Tue 13th Wed 14th Thu 15th Fri 16th Sat 17th Sun 18th When a user clicks a link, I want the selected link to change colour. All other links should remain the same colour, only changing when selected. Then going back to default colour when another link is selected. The links pass a query string to get data from a MySql database. If I was developing a static html page this would be no problem at all. As I would be able to uniquely identify each page and style the links accordingly. However these links are dynamically generated using PHP built date function. I have read countless online tutorials to try and solve this problem but unfortunately almost all of these are based static html pages where each page can be uniquely identified. I am seriously stuck and will appreciate assistance. Thanks in advance. Here is the code of my test page. <?php for($time = strtotime('-2 days'), $i=0; $i < 6; $time = strtotime('-1 days', $time), $i++) { if($i != 0) echo " "; echo '<a href="/catch-up/?date=' . date("d-m-Y", $time) . '">' . date("D jS", $time) . "</a>\n"; } ?>
  24. Hey ignace. Hijack all you want. I encourage it. Your guys have been great help I will now look and see if can implement that sloution. Will report back. Properly to ask even more questions. Thanks again
×
×
  • 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.