Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. If you do not want the trailing zero's, maybe you should clean them with this function <?php function clean_dec($number){ $pos = strpos($number, '.'); if($pos === false) { //integer return $number; }else{ //decimal return rtrim(rtrim($number, '0'), '.'); } } $dec_array = array("80","80.0","80.25","80.00","0.80","80.000","80.0000"); foreach($dec_array as $numb){ echo clean_dec($numb)."<br />"; } ?>
  2. I can see some changes, especially if webgl becomes common usage. See just some examples in 3d Some of these are very cool. http://alteredqualia.com/ http://www.ibiblio.org/e-notes/webgl/webgl.htm I have mixed emotions about the new html5. Interactive webpages are cool, but not when you don't want to load a pile of stuff you do not want to see. Waiting for webpages to load will truly suck, it will be like when people started making flash based sites. Just because people have faster connections doesn't mean they should have to use it just to view a webpage. The usage of <video></video> and <audio></audio> tags can be useful, among the other ones. I guess if want to make something profitable..a plugin to fix all the broken websites there will be, and currently is?
  3. I agree with the 2 posters above. Most of the so called search engines piggyback off others, and are actually metasearch engines, meaning they are just a tool to search actual search engines data. It's certainly not an easy task to create your own search engine and crawler. Many search engines existed, the good ones were bought, the others vanished. Here are a few issues will have, and is lot's of unforseen hurdles. charsets and languages relative urls fixing urls cases and properly encoded parsing urls in a few ways will be required duplicate data (checking if the data already exists every time is costly, may be best to remove duplicates timely through a script) properly sanitizing the data crashing databases or corrupt data (one hiccup can ruin your day or week) special pattern matching if wanted all types of images if doing an image search, to get the images data must download it first. if wanted any javascript would have to write many types of pattern matching for those you need adequate bandwidth, harddrive space, cpu and memory Crawling many of the links to get the information takes time and resources. You could help the load across a few machines. Displaying the content in a fast method is even harder, when get many millions+ of results. I've been working on my search engine/index for about 5 years now. Two years of it was just in thought and testing for better methods. I always hear about "google algorithm", what could they possibly do special? Their results go by paying customers and who's ranked higher at alexa. I'm pretty sure they scrape anything and all they find. My guess would be they try to display data with the most popular keywords first. (most likely saving users search inputs) Can easily make filters for weeding out any unwanted sites or content to crawl, or bogus sites. If you look at their possible "About 697,000,000 results (0.28 seconds)", that's surely some fictitious round number there. I assume they display up to x amounts of content, usually like 87 pages max? They do go by date, and if none for that date exists, is displayed when they do have the data. Obviously they store data by date to each server, or multiple servers, and that is how can pull faster results, plus also caching. I wrote a post a while ago on the same subject. You may want to look into doing the crawler with python , use cassandra for the database and sphinx to display the results with an advanced search. I use php/mysql and fulltext for mine, for now anyway. I guess my advice would be to start scraping front pages of sites to get a more variety of data and their best content, later on start scraping their individual pages. Try not to keep hitting sites continuously or they will ban you possibly.
  4. post your current code
  5. Try downloading an editor that won't convert quotes, and also has code highlighting. notepad2 thorpe clearly showed you what to replace his last post. a “ is different than " and will not work also you have a double quote after session_start(); on your last code shown
  6. Did you look through their bakery? http://bakery.cakephp.org/articles/index/body:tutorial
  7. the following 2 methods can do this <?php echo "<a href='#'><img src='Somefolder/animage.jpg' width='125' height='156' alt='some image' /></a>"; echo "<a href=\"#\"><img src=\"Somefolder/animage.jpg\" width=\"125\" height=\"156\" alt=\"some image\" /></a>"; ?> but you can also break in and out of php if desire ?> <a href="#"><img src="Somefolder/animage.jpg" width="125" height="156" alt="some image" /></a> <?php
  8. The above code will only fetch the link itself and not the title of the link..or if was an image. Plus would not handle any self links. If your goal is to just display exactly what is on that page but not using an iframe. <?php $input = @file_get_contents('http://br.4ce.info/'); if(!$input){ echo "No Recommended Sites"; } else { echo $input; } ?> This will not work for all pages, but for your example I believe is the easiest route. I do have piles of code for getting links in many different ways, fixing relative links, parsing images/links/data. Using DOM or something like simplehtmldom would be good ways.
  9. <?php $frontimage = "/hotelimages/". $img_dir . "/" . $front . $ext; ?> <div id="topframe"> <?php if (file_exists($frontimage)) { ?> <img src="/image.php?width=245&height=245&cropratio=1:1&image=/<?php echo $img_folder.$image ;?>" alt="<?php echo ucwords($row_rs_properties['est_name']);?>" class="fltrt" border="1"/> <?php } else { ?> <img src="/image.php?width=245&height=245&cropratio=1:1&image=<?php echo "/hotelimages/". $img_dir . "/" . $front . $ext; ?>" alt="<?php echo ucwords($row_rs_properties['est_name']);?>" class="fltrt" border="1"/> <?php } ?> </div>
  10. But here is a simple way to explode the search words and insert it into the query, you may also use AND versus the OR $searchTerms = explode(' ', $productname); $searchWords = array(); foreach ($searchTerms as $searchwords) { $searchwords = trim($searchwords); if (!empty($searchwords)) { $searchWord[] = "name LIKE '%$searchwords%'"; } } $query2 = mysql_query("SELECT * FROM product WHERE ".implode(' OR ', $searchWord).");
  11. I found another post I responded to explaining it in more detail with some example fulltext queries that I use. You should create fulltext indexes in mysql for any AND,OR values you will be looking within to speed the search queries up. http://www.phpfreaks.com/forums/index.php?topic=337024.msg1588290#msg1588290 I might as well mention sphinx search as well.
  12. Look into using fulltext search , as it will tailor to your needs more versus using like. You can use a checkbox stating which type of search you want, have one set up as a default if no search type selected. Have multiple queries using if/else or a switch statement that will call upon a specific mysql query depending on the search type..
  13. it's <a href not <a ref here is a simple way by wrapping it in double quotes, and all single quotes within echo "<a href='http://localhost/index.html'>Click here to enter another record</a>";
  14. My best advice for you would be looking into doing fulltext searches
  15. I usually just add a number to the front and save as that, keeping the newest code the original name. After a while i tend to shuffle them off to another drive or burn them...just in case ever needed them. But you can look into github for keeping your latest code together and up to date. Download git
  16. In that code, there is a tabs.php file this would be the area where you insert any new data you would want displayed there <?php $p = $_GET['id']; switch($p) { case "1": echo '<h2>Google</h2>Content goes here !<br style="clear:both;" />'; break; case "2": echo 'Yahoo content ?<br style="clear:both;" />'; break; case "3": echo 'My hotmail content goes here...<br style="clear:both;" />'; break; case "4": default: echo 'Twitter status update <br style="clear:both;" />'; break; } ?>
  17. Your entire php block, from <?php to ?> needs to be properly echoed, escaping all quotes. but I see no need, as the only php code i see there is the $text variable is this the tutorial? http://blog.chapagain.com.np/simple-and-easy-jquery-tabs-with-ajax-and-php/ I downloaded the source, tested it and works just fine.
  18. Just as KevinM1 stated. in your first foreach foreach($pqPhrases as $pqPhrase) your supposed to echo $pqPhrase, not $pqPhrases
  19. I had some free time, so decided to add some more to this. placeholders for form and center it moved messages lower creation of text file show all quotes or from just a certain author linked author from each quote list all authors paginated results all you need is this one script and to name it for use, and some style <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Add A Quotation</title> <style type="text/css"> p.text { font-family: cursive; font-style: normal; font-variant: normal; font-weight: normal; font-size: medium; line-height: 1em; word-spacing: 1ex; letter-spacing: normal; text-decoration: none; text-transform: capitalize; text-align: left; text-indent: 0ex; } </style> </head> <body> <?php $quote = htmlentities(strip_tags(trim($_POST['quote'])), ENT_QUOTES); $name = htmlentities(strip_tags(trim($_POST['name'])), ENT_QUOTES); // Identify the file to use: $file = 'quotes.txt';//name your text file to save the info //if file does not exist create it if(!file_exists($file)){ fopen($file, 'w') or die("can't open file"); } //pagination and display function function paginate($display, $pg, $total) { /* make sure pagination doesn't interfere with other query string variables */ if(isset($_SERVER['QUERY_STRING']) && trim( $_SERVER['QUERY_STRING']) != '') { if(stristr($_SERVER['QUERY_STRING'], 'pg=')) $query_str = '?'.preg_replace('/pg=\d+/', 'pg=', $_SERVER['QUERY_STRING']); else $query_str = '?'.$_SERVER['QUERY_STRING'].'&pg='; } else $query_str = '?pg='; /* find out how many pages we have */ $pages = ($total <= $display) ? 1 : ceil($total / $display); /* create the links */ $first = '<a href="'.$_SERVER['PHP_SELF'].$query_str.'1">&#38;#171; </a>'; $prev = '<a href="'.$_SERVER['PHP_SELF'].$query_str.($pg - 1).'"> &#38;#139;</a>'; $next = '<a href="'.$_SERVER['PHP_SELF'].$query_str.($pg + 1).'"> &#38;#155;</a>'; $last = '<a href="'.$_SERVER['PHP_SELF'].$query_str.$pages.'"> &#38;#187;</a>'; /* display opening navigation */ echo '<div><p align="center">'; echo ($pg > 1) ? "$first : $prev :" : '&#38;#171; : &#38;#139; :'; /* limit the number of page links displayed */ $begin = $pg - 4; while($begin < 1) $begin++; $end = $pg + 4; while($end > $pages) $end--; for($i=$begin; $i<=$end; $i++) echo ($i == $pg) ? ' ['.$i.'] ' : ' <a href="'. $_SERVER['PHP_SELF'].$query_str.$i.'">'.$i.'</a> '; /* display ending navigation */ echo ($pg < $pages) ? ": $next : $last" : ': &#38;#155; : &#38;#187;'; echo '</p></div>'; } /* set pagination variables */ $display = 10; $pg = (isset($_REQUEST['pg']) && ctype_digit($_REQUEST['pg'])) ? $_REQUEST['pg'] : 1; $start = $display * $pg - $display; //if no name inserted use anonymous as name if(!isset($_POST['name']) || $name == ""){ $name = "anonymous"; } // Check for a form submission: if($_SERVER['REQUEST_METHOD'] == 'POST') { //perform actions only if was POST from form if(!empty($_POST['quote'])) { //continue to write to file if contains data if(is_writable($file)) { // Confirm that the file is writable. //add a new quote to end of file $write = fopen($file, 'a+'); $message = "$quote|$name\r\n"; fputs($write, $message); fclose($write); //show any messages //quote stored $message = '<p style="color: green;">Your quotation has been stored.</p>'; } else { //Could not open the file. $message = '<p style="color: red;">Your quotation could not be stored due to a system error.</p>'; } } else { // Failed to enter a quotation. $message = '<p style="color: red;">Please enter a quotation!</p>'; } } // End of submitted IF. //end of inserting quote ?> <h1>Write a quote</h1> <div align="center"> <form action="" method="post"> <input type="text" name="name"placeholder="Your name" /><br /> <textarea name="quote" rows="5" cols="30" placeholder="Enter your quote here."></textarea><br /> <input type="submit" name="submit" value="Add This Quote!" /> </form> <?php //start of display //show message if exists if($message){ echo $message; } ?> </div> <?php //get author name from address bar $author = trim($_GET['author']); //if file does exist, retrieve the data from it if (file_exists($file)) { $data = array();//define array $show_line = array();//define array $data = file($file);//array for each line in file $data = array_reverse($data);//reverse the display order //loop through the results and explode quotes and authors foreach ($data as $line) { $author_name = end(explode("|",$line));//explode author from line for matching author content $authors[] = $author_name;//create array of all authors //to see just one authors quotes if(isset($_GET['author']) && $_GET['author'] != ""){ $author = $_GET['author']; if(preg_match("/$author/i", $author_name)){ $show_line[] = trim($line); } } else { $show_line[] = trim($line);//otherwise show all quotes } } //link to show all authors, same as main page echo "<a href='index.php'> All Authors </a>"; $authors = array_unique($authors);//remove duplicate authors for links asort($authors);//sort ascendinding order //loop all the author links foreach($authors as $show_author){ echo "<a href='?author=$show_author'> $show_author </a> "; } //count displayed quotes $total = count($show_line); echo "<br />Total quotes: $total<br />"; //slice results array for pagination $show = array_slice($show_line, $start, $display); //show page navigation paginate($display, $pg, $total); //loop results paginated foreach ($show as $show_info) { $explode_info = explode("|", $show_info); $show_quote = stripslashes(html_entity_decode($explode_info[0])); $show_name = stripslashes(html_entity_decode($explode_info[1])); echo "<p class='text'>$show_quote</p> <a href='?author=$show_name'>$show_name</a>"; } //show page navigation paginate($display, $pg, $total); } ?> </body> </html>
  20. I like mjdamato's method as that will only query the selected or populated items from the form. I usually like to insert default values if none were inserted, if I want all the results to be displayed. But take this simple example checking if all the fields of the form have a value. <html> <body> <form action="" method="post"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> City: <input type="text" name="city" /> <input type="submit" /> </form> <?php if(isset($_POST)){ foreach($_POST as $post_data){ if(empty($post_data)){ echo "You have not completely filled out the form"; EXIT; } } print_r($_POST); } ?> </body> </html>
  21. The best way to do this would be saving to a database to retrieve the information easily in many ways. But try out this example using a single file and flat file as you did. <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Add A Quotation</title> <style type="text/css"> p.text { font-family: cursive; font-style: normal; font-variant: normal; font-weight: normal; font-size: medium; line-height: 1em; word-spacing: 1ex; letter-spacing: normal; text-decoration: none; text-transform: capitalize; text-align: left; text-indent: 0ex; } </style> </head> <body> <?php // add_quote.php /* This script displays and handles an HTML form. This script takes text input and stores it in a text file. */ $quote = $_POST['quote']; $name = $_POST['name']; // Identify the file to use: $file = 'quotes.txt'; if($_POST['name'] == ""){ $name = "anonymous"; } // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. if ( !empty($_POST['quote']) && ($_POST['quote'] != 'Enter your quotation here.' ) ){ // Need some thing to write. if (is_writable($file)) { // Confirm that the file is writable. //add a new line to end of file $write = fopen($file, 'a+'); $message = "$quote|$name\r\n"; fputs($write, $message); fclose($write); // Print a message: print '<p>Your quotation has been stored.</p>'; } else { // Could not open the file. print '<p style="color: red;">Your quotation could not be stored due to a system error.</p>'; } } else { // Failed to enter a quotation. print '<p style="color: red;">Please enter a quotation!</p>'; } } // End of submitted IF. // Leave PHP and display the form: ?> <form action="" method="post"> <p>Name:<input type="text" name="name"/><br /> <textarea name="quote" rows="5" cols="30">Enter your quotation here.</textarea><br /> <input type="submit" name="submit" value="Add This Quote!" /> </form> <?php if (file_exists($file)) { $data = array(); $data = file($file); $data = array_reverse($data); $total = count($data); echo "<br />Total quotes: $total<br />"; foreach ($data as $line) { $line = trim($line); $explode_line = explode("|", $line); $show_quote = $explode_line[0]; $show_name = $explode_line[1]; echo "<p class='text'>$show_quote</p> $show_name"; } } ?> </body> </html> and the quotes.txt file are saved in this format, seperated by a pipe | feel the heat|anonymous Smart programmers make computers not be dumb|Quick amazing things happen to amazing people|mister amazing
  22. I'm no expert at this. But I do know that firefox locks files, it seems that you have no permission through JS for that user in firefox.
  23. If you are unsure of how much your time is worth, I doubt anyone else will have a better estimate. Throw them the upper price that you feel is worth doing, if they want cheaper can lower it from there.
  24. This should be able to do a simple page your own site, or also from a url <?php if(isset($_GET['frame']) && $_GET['frame'] != ""){ $frame = $_GET['frame']; } else { $frame = "./"; } ?> <iframe src="<?php echo $frame;?>" border="0" framespacing="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" frameborder="0" height="100%" scrolling="yes" width="100%"></iframe>
  25. well it should really be this if are iframing from a different domain <?php $frame = $_GET['frame']; if(isset($_GET['frame']) && $_GET['frame'] != ""){ ?> <iframe src="<?php echo $frame;?>" border="0" framespacing="0" marginheight="0" marginwidth="0" vspace="0" hspace="0" frameborder="0" height="100%" scrolling="yes" width="100%"></iframe> <?php } else { echo "no frame specified"; } ?>
×
×
  • 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.