Jump to content

DeanWhitehouse

Members
  • Posts

    2,527
  • Joined

  • Last visited

Everything posted by DeanWhitehouse

  1. Also are you sure that your mod_rewrite works properly?
  2. Huh? Did you read what i wrote, the latest reply will be on the last page but i need to get to a specific reply which might be on the third. Normally (without pagination) I would do site.com/file.php#reply_5 or something but with pagination that wouldn't work, i would need the page number.
  3. Just a little warning, first off not all hosts will allow mod rewrite, second off i believe it can cause problems with some search engines as it looks for a directory then and not a file, and third if the user or you try and use site.com/productname/ it won't work it has to be site.com/productname
  4. Just wondering, i have seen on sites that they take the user to the latest post or whatever even when using pageination but how does it work does it have to calculate what page it would be on based on the amount of replies in the database.
  5. as i said arguments and if statments
  6. That can all be achieved with functions stored in one page, but if you want to get more advanced then use OOP
  7. Have the function allow arguments and then have if statements in the functions
  8. I think it would be better to just make a file containing all your functions and include it on all pages.
  9. Hmm, have you tried contacting your host about this or is it localhost?
  10. This might help, it is not using dom http://djw-webdesign.awardspace.com/code.php?snippet=13 or http://djw-webdesign.awardspace.com/code.php?snippet=1 or this might work $code = "<a href=\"test\">test</a>"; $code = preg_replace("/\<a href=([^\[]+)\>(.*?)\<\/a\>/","//1",$code); echo $code;//should print test
  11. Your missing a mime type, try looking at the manual on how to use the mail feature to send html emails http://uk2.php.net/manual/en/function.mail.php
  12. Lol, ok, if you want more help feel free to add me on msn and i can give you more assistance (my email is in my profile)
  13. O ok, well i modified this one so it similar (a bit) to mine. <form action="search1.php" method="get" name="search"> <div align="center"> <input name="q" type="text" value="<?php echo $q; ?>" size="15"> <input name="search" type="submit" value="Search"> </div> </form> <p> <?php //connect to database $hostname="host"; $username="user"; $password="********"; $dbname="users"; //open database connection mysql_connect($hostname,$username,$password); mysql_select_db($dbname); //specify how many results to display per page $limit = 10; // Get the search variable from URL if(isset($_GET['q'])) $var = $_GET['q'] ;//Removed the @ as this suppresses errors, better to use an if statment else echo "You must enter a search parameter";//message to print if there is no get var passed //only allow alphanumeric ***--> I probably screwed this up but it seems to work except it displays "no record of found" when submitted with nothing in the search bar if (!ereg("^[A-z0-9]*[']?[A-z0-9]*$",$var)) { //trim whitespace from the stored variable $trimmed = trim($var); //separate key-phrases into keywords $trimmed_array = explode(" ",$trimmed); // check for an empty string and display a message. if (strlen($trimmed) == 0) $resultmsg = "<p><b>SEARCH ERROR</b></p><p>Only enter letters or numbers: no spaces, dashes or special characters</p>" ; $row_count = 0; // Build SQL Query for each keyword entered foreach ($trimmed_array as $trimm) { // EDIT HERE and specify your table and field names for the SQL query $query = "SELECT * FROM table_1 WHERE field_1 LIKE '\"$trimm\"' ORDER BY field_1 DESC" ; // Execute the query to get number of rows that contain search kewords $numresults = mysql_query ($query) or die ("Couldn't execute query: Reason; ".mysql_error()); $row_num_links_main =mysql_num_rows ($numresults); $row_count += $row_num_links; // next determine if 's' has been passed to script, if not use 0. // 's' is a variable that gets set as we navigate the search result pages. if(!isset($s)) $s=0; // now let's get results. $query .= " LIMIT $s,$limit" ; $numresults = mysql_query ($query) or die ("Couldn't execute query: Reason; ".mysql_error()); while($row = mysql_fetch_array($numresults)) { echo "<b>Serial: </b>" . $row['id'];//enter the proper row names echo "<b>Make: </b>" . $row['fname']; echo "<b>Model: </b>" . $row['model']; echo "<b>Caliber: </b>" . $row['city']; echo "<b>Caliber: </b>" . $row['state']; } } //end foreach ?> </p> It might need some work, here is my search feature used on my site <div class="post"> <h1 class="title">Search</h1> <div class="entry"> <p> <form id="searchform" method="get" action=""> <input type="text" maxlength="20" name="query" id="s" size="15" value="<?php if(isset($_GET['query'])){echo $_GET['query'];}?>" > <br> <input type="submit" value="Search" id="x" > </form> </div> </div> <?php if(isset($_GET['query'])) { $search = stripslashes($_GET['query']); $search = mysql_real_escape_string($search); $search = trim($search); if(strlen($search) < 2) echo "<div class=\"entry\">Please enter two or more values to perform a search</div>"; else { $sql = "SELECT COUNT(*) FROM djw_snippet WHERE `title` LIKE '%".$search."%' OR `poster` LIKE '%".$search."%' OR `desc` LIKE '%".$search."%'"; $result = mysql_query($sql); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if if($totalpages > 1) echo "<div class=\"post\"><h2 class=\"title\">Page $currentpage out of $totalpages</h2></div>"; // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT * FROM `djw_snippet` WHERE `title` LIKE '".$search."' OR `poster` LIKE '%".$search."%' OR `tags` LIKE '%".$search."%' ORDER BY time DESC LIMIT $offset, $rowsperpage";//removed OR `example` LIKE '%".$search."%' and OR `code` LIKE '%".$search."%' $result = mysql_query($sql); // while there are rows to be fetched... $snip_count = mysql_num_rows($result); if(strlen($search) > 30) $r = substr($search,0,30)."..."; else $r = $search; if($snip_count == 1) $c = $snip_count." result found - "; else $c = $snip_count." results found - "; echo "<p class=\"byline\">".$c.$r."</p><div class=\"entry\">"; if($snip_count == 0) { echo "<br>Sorry there are no results that match your criterea"; } else { while($rows = mysql_fetch_assoc($result)) { $tags = $rows['tags']; if(substr_count(strtolower($tags),strtolower($search)) > 1) { $pos = stripos($tags,$search); $len = strlen($search); $tags = substr_replace($tags,"",$pos,$len); } $tags = str_replace(","," - ",$tags); $tags = str_ireplace($search,"<b style=\"color:#FFFFFF;\">".$search."</b>",$tags); $title = ucfirst($rows['title']); echo "<br><a href=\"http://djw-webdesign.awardspace.com/code.php?snippet=".$rows['id']."\">".$title."</a> - Posted by ".ucfirst($rows['poster'])."<br> Tags: ".$tags; } } echo "</div></div>"; /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?query=$search&currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?query=$search&currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { if($totalpages > 1) echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?query=$search&currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page if($totalpages > 1) echo " <a href='{$_SERVER['PHP_SELF']}?query=$search&currentpage=$nextpage'>></a> "; if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?query=$search&currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ } } ?>
  14. If you give me about 5-10 mins i will post up what should be a working version
  15. Works for me $str = 'tes"t'; echo addslashes($str);//prints tes\"t
  16. It might be something wrong with your headers on the code, or could be because of the email address you are sending to (or if you are sending multiple emails)
  17. do you want to remove it? If so use str_replace, or use htmlentities on it to turn the quote into a html special char
  18. For the second question you can use an if statement, quite simple. For the first question maybe use a multi-dimensional array, although this will require changing some of your pages which are using this array.
  19. Looking at the code i will assume you didn't write this, my advice would be to learn what the code you have does and how to use loops with mysql queries.
  20. Have you even looked at your sql statement ? $userrating = mysql_query("SELECT service_rating FROM ratings WHERE u_id = '$u_id' && s_id = $s_id") Should be $userrating = mysql_query("SELECT service_rating FROM ratings WHERE u_id = '$u_id' AND s_id = '$s_id'")
  21. Have a look at the tutorial on this site for pagination, it will explain it all.
  22. Then you either didn't open the window with JS or you are doing it wrong, however please post your reply in the JS forum if you want help with it.
×
×
  • 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.