Jump to content

Michan

Members
  • Posts

    115
  • Joined

  • Last visited

    Never

Everything posted by Michan

  1. Thank you very much for your time, this has helped a lot
  2. Thank you very much for this. It tidies it all onto a single line, but converts all of the <, >, ", ', &, etc into their HTML codes. Is there a way to remove the HTML returns without converting all of the HTML codes? Many thanks again!
  3. I already have line breaks in there, I'd just like to remove the additional whitespace as it's causing problems in Javascript.
  4. Hi, I seem to be stuck. I've tried replacing \n and \r, but it doesn't seem to have any effect on the code, which looks something like this: Line 1<br /> Line 2<br /> Line 3 How would I fix this with a function so it would display in HTML as the following? Line 1<br />Line 2<br />Line 3 Many thanks in advance, - Mi
  5. For this chunk: if ($eventDate['year'] > $currentDate['year']) { // Event is upcomming $eventsArrayUpcomming[] = $eventData; } elseif ($eventDate['year'] == $currentDate['year']) { if ($eventDate['month'] > $currentDate['month']) { // Event is upcomming $eventsArrayUpcomming[] = $eventData; } elseif ($eventDate['month'] == $currentDate['month']) { if ($eventDate['day'] > $currentDate['day']) { // Event is upcomming $eventsArrayUpcomming[] = $eventData; } elseif (if $eventDate['day'] == $currentDate['day']) { // Event is today $eventsArrayToday[] = $eventData; } elseif (if ($eventDate['day'] < $currentDate['day']) { // Event has passed $eventsArrayPassed[] = $eventData; } } elseif ($eventDate['month'] < $currentDate['month']) { // Event has passed $eventsArrayPassed[] = $eventData; } } elseif ($eventDate['year'] < $currentDate['year']) { // Event has passed $eventsArrayPassed[] = $eventData; } You could simply convert the event year, month, and day to a timestamp and match it with time(). From what I see, you don't need to convert it to the year, month, and day. $eventDate['date'] = mktime(0, 0, 0, $eventDate['month'], $eventDate['day'], $eventDate['year']) if (date('jmY', $eventDate['date']) > date('jmY', time())) { // Event is upcomming $eventsArrayUpcomming[] = $eventData; } elseif (date('jmY', $eventDate['date']) == date('jmY', time())) { // Event is today $eventsArrayToday[] = $eventData; } else { // Event has passed $eventsArrayPassed[] = $eventData; }
  6. Alright, then give this a try: RewriteRule ^([^/]+)(/([^/]+))?.html$ /sitewonders/index.php?pg=detail&catId=%3&catTitle=%1 Good luck!
  7. Why would you want to get rid of the $_GET part of it? That's the only way of reading data sent through pages using $_GET. You could always put something like this at the start of the page which is receiving the data: <?PHP $variable = $_GET['variable']; $variable2 = $_GET['variable2'];
  8. Try this: RewriteRule ^aboutus.html$ /sitewonders/index.php?pg=detail&catId=1&catTitle=2
  9. Maybe you can show us some code?
  10. Hi, I'm having problems trying to retrieve certain values from a function. The function is below: function getpage($pageid,$number,$comic,$total,$thispage) { $getpage = mysql_query('SELECT pageid FROM pages WHERE page='.$comic.' AND previouspg='.$pageid); $page = mysql_fetch_array($getpage); $pageorder[$number] = $page['pageid']; if($number != $total) getpage($page['pageid'],($number+1),$comic,$total,$thispage); if($pageid = $thispage) $thepage = $number; } After running it (and getting some results; I've tested it with an echo), how do I get $thepage and $pageorder (an array) from the function? I've tried return $thepage; and return $pageorder; but have had no success there ($thepage and $pageorder were empty). Any help would be greatly appreciated! Thanks in advance, - Mi
  11. echo "<tr><th>Image</th>"; echo "<td>"; echo "<img src='cars/".$row['image']."' width='100' height='100'/>"; echo "</td></tr>"; That's the easy way. If you're still having problems, can you post whatever is on that line? Thanks.
  12. You could simply use width and height in the <img> tag, if the size reduction is for the user interface rather than the bandwidth.
  13. Hi, I'm stuck on a bit of code. I have more than one <div>, and depending on which "comic" you choose, I'd like to load content into the specified <div>. How would I get about doing it? The code pretty much explains itself below. <script type="text/javascript"> var xmlHttp function selectcomic(str,div) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="comics.php"; url=url+"?getresult="+str; xmlHttp.onreadystatechange=stateChanged(div); xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged(div) { if (xmlHttp.readyState==4) { document.getElementById(div).innerHTML=xmlHttp.responseText; } } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } </script> Comic: <a href="" onclick="selectcomic(\'1\',\'div1\'); return false">Comic 1</a> <a href="" onclick="selectcomic(\'2\',\'div2\'); return false">Comic 2</a> <a href="" onclick="selectcomic(\'3\',\'div3\'); return false">Comic 3</a> <div id="div1">None selected!</div> <div id="div2">None selected!</div> <div id="div3">None selected!</div> Thanks in advance!
  14. Hi, I'd like to send arguments with onreadystatechange, but I'm really struggling. I know you can't directly send arguments with it, but surely there must be another way? Basically, I have one function that I would like the result of to be placed into one of a multitude of divs (up to 30). I'm really struggling to do this The divs are labelled from div1 - div30. Any help would be extremely appreciated. var xmlhttp; function loadXMLDoc(url) { xmlhttp=null; if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc. xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp!=null) { xmlhttp.onreadystatechange=state_Change; xmlhttp.open("GET",url,true); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } } function state_Change() { if (xmlhttp.readyState==4) {// 4 = "loaded" if (xmlhttp.status==200) {// 200 = "OK" document.getElementById("div1").innerHTML=xmlhttp.responseText; } else { alert("Problem retrieving data:" + xmlhttp.statusText); } } } Many thanks.
  15. You have just saved me. Thanks a bunch!
  16. Hi, I have user-created fields that are displayed in a form and have different names (defined by ID). I can print the data sent by $_POST with a print_r($_POST), but how would I actually use it? For example, if a selection menu with the name "myuniquetext" returned "abc", how would I echo "For myuniquetext, you typed abc"? Thanks in advance!
  17. Hi, I've managed to successfully rewrite subdomains to folders, so that http://username.mysite.com will go to http://mysite.com/user.php?user=username However, I'm having trouble directing extensions of that subdomain to other areas of the site. For example, each user has their own blog and photo gallery, so the following urls should exist: http://username.mysite.com (profile) http://username.mysite.com/blog (blog) http://username.mysite.com/photos (photos) Here is my code: RewriteCond %{HTTP_HOST} !(^\www\b¦^\ftp\b¦^\mail\b¦^\webmail\b).mysite\. RewriteCond %{HTTP_HOST} ^www.([^/]+).mysite.com/blog/?$ [OR] RewriteCond %{HTTP_HOST} ^([^/]+).mysite.com/blog/?$ RewriteRule (.*) blog.php?user=$1 [L] RewriteCond %{HTTP_HOST} !(^\www\b¦^\ftp\b¦^\mail\b¦^\webmail\b).mysite\. RewriteCond $1 !^blog/? RewriteCond %{HTTP_HOST} ^www.([^/]+).mysite.com/?$ [OR] RewriteCond %{HTTP_HOST} ^([^/]+).mysite.com/?$ RewriteRule (.*) user.php?user=%1 [L] As you can see, I've started with the blog, but it just keeps giving me an error every time I try typing the url (although the profile continues to display the page correctly). I've tried searching but couldn't find any success, so any insight/help would be extremely appreciated! Thanks in advance.
  18. Hi everyone, I'm trying to select any url that does not consist of a "\" (backslash), "mail", "ftp", or "www". This is what I have: ([^/|(www|ftp|mail)]+) However, that blocks out any urls that contain the letters "w", "f", "t", "p", "m", "a", "i", and "l". Other urls work fine. How should this expression look if I want to block the whole words rather than the letters of them? Thanks in advance!
  19. You can't hide Javascript from the user. You could put it in an external file and call it, which will make it harder for the user to gain access to your code, but it's not possible to hide browser-driving code from the.. browser.
  20. Thanks! I read the manual but couldn't find this for the life of me. You've saved me a whole lot of time!
  21. You can't convert Javascript to PHP, but Javascript is extremely similar to PHP. The odds are that if you have a function or chunk of code in Javascript, you can probably tweak it a little to a similar thing in PHP. However, PHP is read by the server, whereas Javascript is read by the browser, so different types of things can be manipulated in the different languages. Like many other languages, they compliment each other very well.
  22. Hi, I'm stuck with an array. How would I count duplicate results in array? [0] => red [1] => blue [2] => red [3] => blue [4] => red Is there a way I can easily count these results so it returns: [0] => red(3) [1] => blue(2) ..or something similar? Thanks in advance!
  23. You can't divide by zero. Somewhere in your script there's an equation that's dividing a number by zero; hunt it down and try to fix it that way?
×
×
  • 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.