Jump to content

BlackenedSky

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by BlackenedSky

  1. I managed to solve my own problem in the end, although it's far from pretty or efficient! But hey, it works at least Basically, I just got rid of the limit on the 1st query, then from that put all the refNo's into one loooong "OR" string, and put that into the second query. Downside is the string could contain up to 500 reference numbers so you can see what I mean by it not being efficient, and it will probably cause some errors no doubt once the couple hundred mark is reached, if not easily before! Here's the code: $limit = 'LIMIT ' . ($cPage - 1) * $perPage . ',' . $perPage; $pList = mysql_query("SELECT refNo FROM propertyList WHERE (type='$type' && areaID LIKE '$area' && price >= '$minprice' && price <= '$maxprice') ORDER BY price,areaID ASC"); if (!$pList || mysql_num_rows($pList) < 1) { echo "No properties found meeting your criterea."; return; } $arr = array(); while ($row = mysql_fetch_array($pList)) { $arr[sizeOf($arr)] = $row['refNo']; } $arr = "(refNo='" .implode($arr,"' OR refNo='"). "')"; if ($pool) { if ($garage) { //pool and garage $pageCount = mysql_query("SELECT COUNT(refNo) FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && pool='1' && garage='1' && propsize>='$propsize' && plotsize>='$plotsize')"); $hList = mysql_query("SELECT refNo FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && pool='1' && garage='1' && propsize>='$propsize' && plotsize>='$plotsize') $limit"); } else { //just pool $pageCount = mysql_query("SELECT COUNT(refNo) FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && pool='1' && propsize>='$propsize' && plotsize>='$plotsize')"); $hList = mysql_query("SELECT refNo FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && pool='1' && propsize>='$propsize' && plotsize>='$plotsize') $limit"); } } else { if ($garage) { //just garage $pageCount = mysql_query("SELECT COUNT(refNo) FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && garage='1' && propsize>='$propsize' && plotsize>='$plotsize')"); $hList = mysql_query("SELECT refNo FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && garage='1' && propsize>='$propsize' && plotsize>='$plotsize') $limit"); } else { //neither $pageCount = mysql_query("SELECT COUNT(refNo) FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && propsize>='$propsize' && plotsize>='$plotsize')"); $hList = mysql_query("SELECT refNo FROM houses WHERE ($arr && beds>='$beds' && baths >='$baths' && propsize>='$propsize' && plotsize>='$plotsize') $limit"); } } if (!$pageCount) { echo "No properties found meeting your criterea."; return; } $pageCount = mysql_fetch_row($pageCount); $pageCount = ceil($pageCount[0]/$perPage); $pagination = pagination($pageCount,$perPage,$cPage); $isResult = false; $displayed = false; while ($row = mysql_fetch_array($hList)) { if (!$displayed) { echo $pagination; $displayed = true; } printResult($row['refNo'],false); $isResult=true; } if(!$isResult) echo "No properties found meeting your criterea."; else echo $pagination; @mysql_free_result($hList); @mysql_free_result($pList);
  2. easy to google: e.g. "list of uk postcodes" gave me this: http://en.wikipedia.org/wiki/List_of_postcode_areas_in_the_United_Kingdom copy into txt file, edit as needed, convert using program which will give you the sql code to create the table
  3. Change move_uploaded_file($_FILES["file"]["tmp_name"], $user . "/Music/" . $_FILES["file"]["name"]); to $fName = str_replace(/\s/,"_",$_FILES["file"]["name"]); move_uploaded_file($_FILES["file"]["tmp_name"], $user . "/Music/" . $fName); or something along those lines
  4. Look for a premade table. There's bound to be one out there. Alternatively find a site with a list of the postcodes and convert it to a database using a program such as "csv converter" (not sure if that's the right title). Had to do a similar thing with a list of countries and list of regions. Found a premade database of countries and a text list of regions which I converted using the above program.
  5. You're sending the user id to the page via the variable "hash" not "userid", and it's already md5'd in your URL. hash=".md5($userid) md5($_GET['userid']) Also is userid stored as an md5 in your table? If so why? It adds in extra overhead using it encrypted when there is no need usually. Passwords yes, usernames not really.
  6. It should be: [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}
  7. Hi, I'm attempting to paginate some mysql results but it is proving to be harder than it should be! I have 2 tables - one of these tables contains an index type structure of reference numbers. From this list of reference numbers, I pull those which match certain WHERE criterea. Then I run a query on the 2nd table and pull data from it where the reference number matches, but again this has WHERE criterea relevant to values in the 2nd table. The only problem is this...pagination works fine until it jumps into pulling data from the second table. It is set to pull out 6 results in total for a page, so I pull out 6 results from the first table. This is where the problem comes because then the search in the second table is only within these 6 results, and so can return anywhere from 0 to 6 results (it returns only results which pass the 1st query for table 1, then narrows them based on the type using data in the second table. To better illustrate - you have a tube of smarties, you pull out 6 blue ones as you only want 6. Then you get rid of any that are chipped and give the ones left to your mate (pft, as if. e-numbers are for me!!!) Obviously my pagination method is completely wrong! So yeah, my pages don't always return 6 results if the search criterea is to specific, as it only searches within 6 results at a time because I want it paginated. Anyone got any ideas on how I can solve this problem so that I always have 6 results being output on the page? (Btw, if this is too confusing let me know and I'll try to explain better. Makes sense to me, but then I'm the one who's asking the question!) Here's my code: $limit = 'LIMIT ' . ($cPage - 1) * $perPage . ',' . $perPage; $pList = mysql_query("SELECT refNo FROM propertyList WHERE (type='$type' && areaID LIKE '$area' && price >= '$minprice' && price <= '$maxprice') ORDER BY price,areaID ASC $limit"); if (!$pList) { echo "No properties found meeting your criterea."; return; } $pageCount = mysql_query("SELECT COUNT(refNo) FROM propertyList WHERE (type='$type' && areaID LIKE '$area' && price >= '$minprice' && price <= '$maxprice')"); $pageCount = mysql_fetch_row($pageCount); $pageCount = ceil($pageCount[0]/$perPage); $pagination = pagination($pageCount,$perPage,$cPage); $isResult = false; $displayed = false; while ($pListRow = mysql_fetch_array($pList)) { if (!$displayed) { echo $pagination; $displayed = true; } if ($pool) { if ($garage) { $hList = mysql_query("SELECT refNo FROM houses WHERE (refNo='{$pListRow['refNo']}' && beds>='$beds' && baths >='$baths' && pool='1' && garage='1' && propsize>='$propsize' && plotsize>='$plotsize')"); if ($hList = mysql_fetch_assoc($hList)) { printResult($hList['refNo'],false); $isResult=true; } } else { $hList = mysql_query("SELECT refNo FROM houses WHERE (refNo='{$pListRow['refNo']}' && beds>='$beds' && baths >='$baths' && pool='1' && propsize>='$propsize' && plotsize>='$plotsize')"); if ($hList = mysql_fetch_assoc($hList)) { printResult($hList['refNo'],false); $isResult=true; } } } else { if ($garage) { $hList = mysql_query("SELECT refNo FROM houses WHERE (refNo='{$pListRow['refNo']}' && beds>='$beds' && baths >='$baths' && garage='1' && propsize>='$propsize' && plotsize>='$plotsize')"); if ($hList = mysql_fetch_assoc($hList)) { printResult($hList['refNo'],false); $isResult=true; } } else { $hList = mysql_query("SELECT refNo FROM houses WHERE (refNo='{$pListRow['refNo']}' && beds>='$beds' && baths >='$baths' && propsize>='$propsize' && plotsize>='$plotsize')"); if ($hList = mysql_fetch_assoc($hList)) { printResult($hList['refNo'],false); $isResult=true; } } } } if(!$isResult) echo "No properties found meeting your criterea."; else echo $pagination;
  8. Hi, I'm having trouble displaying unicode characters correctly when using the DOM parser to display strings on the page. Is there any way to get it to display them correctly, or alternatively a built in php function to replace them all with the HTML code version when saving to the database. I have a php function pulling information from a database, and generating an xml document. Characters are being preserved in the database and displayed correctly when not using xml and parsing it. However, characters such as the Euro sign, ñ é etc are not displaying when parsed, just a square character (Pe�br />)which is then in turn screwing up any HTML elements after it. It is vital that I can support them as it is a website in Spanish, and an accent can be applied to ANY character, and the ñ,Ñ characters are common too. However, I got around the Euro sign problem using the HTML character code. As you can imagine it's not really feasible to create a function replacing them all with HTML codes as there is a huge range! Thanks!
  9. update should have worked. check your syntax, and echo "mysql_error()" to see what's wrong, and it will also check if your syntax is valid (only outputs on an error,otherwise blank)
  10. use the php dir functions, and wrap each directory in a paragraph, and set the indent from the left with css or something which increases say 10px for each sub directory or generate an xml file of the dir structure and display it that way either using xls, or javascript
  11. Hi, Having a small nightmare trying to resize an image that is stored in a blob. Anyone had any experience with this? Any help would be great, or a link. Closest I can find is some vague reference to image magic pulling an image from a blob, but that's about it. I DON'T want to have to create a file though to display an image, just pull it from the DB and display it via PHP which is what it currently does. Thanks!
  12. http://www.answermysearches.com/making-firefox-browse-a-local-directory/103/ in short, not possible in firefox without updating firefox settings via config pages. not viable to make every user do this either. better just to tell them to navigate to the location manually. no javascript alternative either as far as i know as javascript dosen't have file permissions. at least I know you can't create files etc... another idea....use an iframe with the src set to the target folder, although not sure if firefox will give the same problem.
  13. the hash iswhat you see when you use page anchors, but it can also be used to store data in the URI. to set the hash use: location.hash = "myhash"; //will give www.whatever.com/index.html#myhash to read the hash from www.whatever.com/index.html#myhash var hash = location.hash; //will give #myhash (you need to drop the # yourself) dynamic loading of pages: http://www.w3schools.com/xml/xml_http.asp for a beginners tutorial with that you can load anything from pages, to images without refreshing the page
  14. or use: onmouseover="document.getElementById('families-head').style.top = 500 + 'px';"
  15. c++ itself cannot create an application window. for that you need to use Win32API (Windows API) and you literally take control of the entire thing, from close messages, to redrawing the window. Unless you are willing to do that, I would advise starting off on another route, either using MFC which uses c++ still, or one of the visual languages as recommended before. Once you get your head around creating and drawing windows, controls etc and how to manipulate them etc, you will be ok, but until then don't even attempt c++. I started out programming with c++ as my 2nd language, basic being my 1st (no, not visual basic, basic). Good for a crash course, but you have to persevere and be prepared to read a hell of a lot of documentation, especially if you are using Win32API. You can use Win32API is visual languages as well with some slight differences if you really want to get into taking total control of you application, but there's really no point. Also, with the intro of vista there is the now a new API to learn. Note: this is pretty much specific to Windows. Linux etc, similar deal, but instead you use APIs for X-Windows,gtk/tcl (can-t remember what aMsn uses) etc..., and again other api in OSx Stear clear of c++ for now unless you want to be thrown in the deep end.
  16. as above. load image from that url, check if img.src is null or whatever. if it is, change the add. add blockers work based on urls. also, we usually have adblockers for a reason - to block ads. why try and annoy those users who have decided they don't want them being shown? sure way to annoy visitors. plus they can easily add the url of any adds you display which aren't already blocked. short of setting up TinyUrls (tinyurl.com), you can't really mask the ads url. I'm not even sure if tinyurl would work or not, but it might since it masks the domain another idea would be to link all ad frames to a single php page, which echos the html from a random ad url. this would mean any ad blockers wouldn't detect the url, as it is done server side
  17. use divs and css to position them. if you want the nav bar to stay always in view on the left, either use javascript to constantly move it down the page as the user scrolls, OR (better) add in an overflow to the div containing the content so only that scrolls, instead of the whole page i.e <div style="position:absolute;top:0px;left:0px;height:123; width 200px;"> asdfasdfasdf </div> <div style="position:absolute;top:0px;left:200px;height:123; overflow:auto"> asdfasdf </div> but obviously tidier
  18. http://www.devshed.com/c/a/JavaScript/Understanding-the-JavaScript-RegExp-Object/ use a RegExp to match the pattern for an email. See that link for a tutorial
  19. line 183 is line 183 of any and all javascript in that page in order. however, if you have external files then it is line 183 of the external file only. repost all your javascript minus the html etc... so it's easier to identify just what line 183 is
  20. I agree, use php, or look into using xmlHttpRequests
  21. Here is a quick bit of code to do it off the top of my head, but by no means the best, and probably full of errors, but hope it's of some use to you. [code] var toolTip = null; document.body.onmousemove = tooltip; function getText(x,y) {     //probably more efficient to use switch statements     if (x = 123 && y = 123) {         return "tooltiptexthere";     } else if (x = 456 && y = 456) {         return "someothertext";     } else return false; } function tooltip(e) {     if (document.all?true:false) e = window.event;     if (e.button != 1) return;     if (document.all?true:false) {         var x =e.clientX + document.body.scrollLeft;         var y=e.clientY + document.body.scrollTop;     } else {         var x=e.pageX;         var y=e.pageY;     }     var text = getText(x,y);     if (!text) {         if (toolTip) toolTip.style.display="none";         return;     }     if (!toolTip) {         toolTip= document.createElement('div');         var txt = document.createTextNode(text);         toolTip.appendChild(txt);         toolTip.style.position="absolute";         document.appendChild(toolTip);     } else {         toolTip.childNodes[0].nodeValue=text;         toolTip.style.left=x;         toolTip.style.top=y;         toolTip.style.display="block";     } } [/code]
  22. change the position of the element using element.style.top or element.style.left in firefox, but in IE use element.offsetTop and element.offsetLeft unless the element is positioned absolutely. no harm in using both to make sure
×
×
  • 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.