Jump to content

BlackenedSky

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

About BlackenedSky

  • Birthday 05/22/1986

Contact Methods

  • Website URL
    http://www.blackenedsky.com

Profile Information

  • Gender
    Not Telling
  • Location
    England

BlackenedSky's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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
×
×
  • 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.