Jump to content

rajivgonsalves

Members
  • Posts

    2,166
  • Joined

  • Last visited

    Never

Everything posted by rajivgonsalves

  1. you got an error on line 35 this if ($src == 'home') { $src = admin.php'; } should be if ($src == 'home') { $src = 'admin.php'; }
  2. do you mean like a confirm box ? or a dialog ?
  3. if your looking for one that checks the starting letter I think the following should do <?php function getBefore($word) { return in_array(strtolower(substr($word,0,1)), array('a','e','i','o','u')) ? 'an' : 'a'; } echo getBefore('english') . '<br />'; echo getBefore('spanish') . '<br />'; ?>
  4. taking your example into consideration this should work <?php $string = '=? utf-8 ? B ? This is an example text ?='; $string = preg_replace("#=\? (.*?) \? (B|Q)? \? (.*?) \?=#", '$3', $string); echo $string; ?>
  5. I think your browser is doing the autofill not the website
  6. its should consider the following <?php $string = 'Sam Neill|William H. Macy|Tea Leoni|'; foreach (explode('|', $string) as $name) { if (!(empty($name))) echo "<a href='/Movies/&actor=" . urlencode($name) ."'>$name</a><br />"; } ?>
  7. You should study the designated site (browse threw it) and see if it has pagination there, then you can modify your script to add parameters so that you only fetch a limited amount of data at each call, this will ensure that your script is light on resources and only processes the amount of data it displays. However if you can't do this, I would suggest putting it in the database. 1) Write a script which processes data add/updates the database every 1/2 hour or 1 hour or which ever time interval you desire (so that your data is up to date) 2) Just write simple scripts to fetch data from the database and list them This will ensure that your listing on your site is fast. hope its helpful
  8. I would suggest parse all the data out and put it in a database, it will be faster and more controllable, then you can use a easy pagination script to achieve the 50 per page. you can do it with the code you already have but you would be parsing the pages everytime, One alternate solution would be parse out the pages and put it in the session and on pagination pick it up from the session instead of again parsing it out again. however if there is alot of data it would be slow.
  9. there is a logical error in your code try this <?php $st = isset($_POST['submit']) ? $_POST['state'] : ''; $urls = array(); if ($st == "AL") { $urls = array("http://auburn.craigslist.org", "http://bham.craigslist.org"); } else if ($st == "AK") { $urls= array("http://anchorage.craigslist.org"); } else if ($st == "AZ") { $urls = array("http://anchorage.craigslist.org"); } foreach ($urls as $url) { $html = file_get_contents("$url/muc/"); preg_match_all('/<a href="([^"]+)">([^<]+)<\/a><font size="-1">([^"]+)<\/font>/s', $html,$posts,PREG_SET_ORDER); //echo "<pre>";print_r($posts); foreach ($posts as $post) { //print $post[0]; //HTML $post[2] = str_ireplace($url,"",$post[2]); //remove domain echo "<a href=\"$url{$post[1]}\">{$post[2]}<font size=\"3\">{$post[3]}<br />"; print "<BR />\n"; } } ?>
  10. You would have to save your files with .php that is how the server identifies and parses out your php files unless you configure the server differently, for different date formatting you can see the following link http://php.net/manual/en/function.date.php there are examples which show you how you can format your date
  11. you can use strtotime with date e.g <?php echo date('F d', strtotime("-3 days")); ?>
  12. you'll have to check your query try echo $query; and see if its showing up correctly, also what is the column type for col_date
  13. this code should help <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="" method="post" name="frm"><table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td> </td> <td> </td> </tr> <tr> <td>Description</td> <td><label> <textarea name="textarea" cols="67" rows="6" onkeyup="document.getElementById('char_count').innerHTML = this.value.length;document.getElementById('char_left').innerHTML = 600 - parseInt(this.value.length);"></textarea> </label></td> </tr> <tr> <td>Number of characters count </td> <td id="char_count">0</td> </tr> <tr> <td>Characters left</td> <td id="char_left">600</td> </tr> </table></form> </body> </html>
  14. hmm.. which array_name[] parameter the code I provided works fine in FF not checked it in IE but it should give you an idea on how to traverse through the elements of the form.
  15. you will have to make sure that the date is in YYYY-MM-DD format e.g 2010-01-05 for it to insert properly otherwise it will be invalid and a 0000-00-00 date will be inserted
  16. Edit: its will match combination of those characters where any one is present http://www.php.net/manual/en/reference.pcre.pattern.syntax.php it will give you and idea on regular expressions syntax.
  17. not perfect but I guess it should give you an idea <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <SCRIPT LANGUAGE="JavaScript"> <!-- <!-- Begin function CheckAll(form, name) { for (var i=0;i<form.elements.length;i++) { var e = form.elements[i]; if (e.type=='checkbox' && e.name.indexOf(name) == 0 && !e.disabled) { e.checked = true; } } } function UnCheckAll(form, name) { for (var i=0;i<form.elements.length;i++) { var e = form.elements[i]; if (e.type=='checkbox' && e.name.indexOf(name) == 0 && !e.disabled) { e.checked = false; } } } // End --> </script> </head> <body> <?php if(isset($_POST[chk])) { for($i=0;$i<5;$i++) { echo $_POST['check_list'][$i]; } echo "hi"; exit(); } ?> This is the HTML code to be kept inside the body tag. <form name="myform" action="check.php" method="post"> <b>Scripts for Web design and programming</b><br> <input type="checkbox" name="check_list[]" value="1">ASP<br> <input type="checkbox" name="check_list[]" value="2">PHP<br> <input type="checkbox" name="check_list[]" value="3">JavaScript<br> <input type="checkbox" name="check_list[]" value="4">HTML<br> <input type="checkbox" name="check_list[]" value="5">MySQL<br> <input type="button" name="Check_All" value="Check All" onClick="CheckAll(this.form, 'check_list')"> <input type="button" name="Un_CheckAll" value="Uncheck All" onClick="UnCheckAll(this.form, 'check_list')"> <input type="submit" name="chk" value="CHK" /> </body> </html>
  18. sorry actually it will replace with \n the first parameter is the match and second is the replacement, the hash is the delimiter you can provide anything like ~ but your expression has to start and end with that mostly people use /, + is match one or more times.
  19. with the expression it will match and replace \r \n \r\n \n\r with \r\n
  20. this var user = document.getElementById("user"); var pass = document.getElementById("pass"); should be var user = document.getElementById("user").value; var pass = document.getElementById("pass").value;
  21. I am not sure what could be wrong with the code but you can use preg_replace instead $text = preg_replace('#[\r\n]+#', "\r\n", $text);
  22. how are you calling this you should just pass the Id as a parameter.
×
×
  • 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.