Jump to content

twitch987

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by twitch987

  1. hey - thanks for the reply.. sorry i had to go out for a few hours earlier - i actually managed it just before i left.. my way is probably the dumbest possible but i got it done lol <?php if ($_POST["bedrooms"] == true) $beds=$_POST["bedrooms"]; if ($_POST["maxrentpm"] == true) $maxrentpm=$_POST["maxrentpm"]; if ($_POST["postcode"] == true) $postal=$_POST["postcode"]; if ($_POST["area"] == true) $area2=$_POST["area"]; if ($_POST["availability"] == true) $availablefrom=$_POST["availability"]; if ($_POST["type"] == true) $propertytype=$_POST["type"]; if ($_POST["order"] == true) $orderby=$_POST["order"]; if ($_POST["maxrentpm"] == true) $maxrentpm2="rentpm <= '".$maxrentpm."'"; if ($_POST["bedrooms"] == true) $beds2="&& bedrooms >= '".$beds."' "; if ($_POST["postcode"] == true) $postal2="&& postcode LIKE '".$postal."' "; if ($_POST["area"] == true) $area22="&& area LIKE '".$area2."' "; if ($_POST["type"] == true) $propertytype2="&& type LIKE '".$propertytype."' "; if ($_POST["order"] == true) $orderby2=" ORDER BY '".$orderby."'"; $query2="$maxrentpm2 $beds2 $area22 $postal2 $propertytype2 $orderby2"; $query="SELECT * FROM lettings WHERE ".$query2.""; $result=mysql_query($query); $num=mysql_numrows($result); ?> my php knowledge is extremely limited so i had to use what i know.. which aint much will definately use your version though thanks mate
  2. ok i've got all the variables worked into it with && so i get specific results.. what i need to do now is somehow make it possible to be less specific.. is there a way to make the query ignore for e.g. " && bedrooms >= '".$beds."' " if $beds doesnt exist or is null? in other words if any of the form fields are left blank, ignore the corresponding part of the query what i have so far: include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $beds=$_POST["bedrooms"]; $maxrentpm=$_POST["maxrentpm"]; $postal=$_POST["postcode"]; $area2=$_POST["area"]; $availablefrom=$_POST["availability"]; $propertytype=$_POST["type"]; $orderby=$_POST["order"]; $query="SELECT * FROM lettings WHERE rentpm <= '".$maxrentpm."' && bedrooms >= '".$beds."' && area LIKE '".$area2."' && postcode LIKE '".$postal."' && type LIKE '".$propertytype."' ORDER BY '".$orderby."'"; $result=mysql_query($query); $num=mysql_numrows($result); dropped the option to search by availability date, decided to make it one of the "order by" options instead to save me a headache
  3. well the idea was to have a set of results which are a "perfect match" and a set of results which are "close matches" obviously that will come at a much later time since i cant even get past this stage lol.. i tried using && which is fine for the perfect match set, however im not entirely sure how to use that either so i've come accross a little snag $beds=$_POST["bedrooms"]; $maxrentpm=$_POST["maxrentpm"]; $postal=$_POST["postcode"]; $area2=$_POST["area"]; $availablefrom=$_POST["availability"]; $propertytype=$_POST["type"]; $query="SELECT * FROM lettings WHERE rentpm <= '".$maxrentpm."' && bedrooms >= '".$beds."' ORDER BY rentpm" && postcode LIKE '"%$postal%$"'; $result=mysql_query($query); $num=mysql_numrows($result); the other variables are yet to be worked into the query area LIKE $area2 availability >= $availablefrom (which is a date xxxx-xx-xx) type LIKE $propertytype
  4. my hopes were raised momentarily there i thought it was going to be in the basic database handling tutorial on this site.. darn
  5. hey thanks for the reply i swapped the query for yours but get the same result.. selecting number of beds works OK with that query, but if i put rent in there too it messes up http://83.170.107.1/~toxxicst/rooftop/search.php
  6. Hey guys.. got a problem using WHERE and i dont know enough about it to identify my problem <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $beds=$_POST["bedrooms"]; $maxrentpm=$_POST["maxrentpm"]; $query="SELECT * FROM lettings WHERE rentpm <= '$maxrentpm' OR bedrooms >= '$beds' ORDER BY rentpm"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> when i leave just rent in there it works, when i leave just bedrooms in there it works, yet with it both just messes it up and returns all the results, so obviously im doing it wrong.. w3schools doesnt cover this the form the variables are coming from is hopefully going to have 6 fields, so 6 different search criteria.. whats the best way to go about this?
  7. you know what, i have got no idea at all. i've been chopping and changing things half asleep for a few hours now just getting more and more frustrated - i dont actually remember doing it.. time for some food and bed.. thanks to all that have helped me on my posts today all the input has helped alot.. and um.. yeah.. sorry for being blonde lol
  8. i knew it had to be something stupid! something very stupid too as if ya look method="post" is in the last <input> tag.. thanks a million man.. i can sleep now! 3am lol.. woot - what a day.
  9. by the way, i think the form is working fine as when i submit the url has all this in it /insert.php?bedrooms=4&bathrooms=1&area=leeds&postcode=LS9+0NN&ref=JDU7362&description=nice+place+to+live&rentpw=50&rentpm=500&deposit=500&availability=2009-01-01&type=flat&address=112+moon&image=http%3A%2F%2Fhealth.discovery.com%2Fcenters%2Fkids%2Fchildproof%2Fimages%2Fhouse_off.gif
  10. tested it on a free account i just set up with a different provider, i get the same results.. its not the form thing heres both files so far the PHP <?php echo "form submitted"; ?> <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die(mysql_error()); foreach ($_POST as $key => $val) echo "key :: $key => value :: $val <br />"; $bedrooms=$_POST['bedrooms']; $bathrooms=$_POST['bathrooms']; $area=$_POST['area']; $postcode=$_POST['postcode']; $ref=$_POST['ref']; $description=$_POST['description']; $rentpw=$_POST['rentpw']; $rentpm=$_POST['rentpm']; $deposit=$_POST['deposit']; $propertynear=$_POST['propertynear']; $availability=$_POST['availability']; $type=$_POST['type']; $address=$_POST['address']; $image=$_POST['image']; $query = "INSERT INTO lettings VALUES ('','$bedrooms','$bathrooms','$area','$postcode','$ref','$description','$rentpw','$rentpm','$deposit','$propertynear','$availability','$type','$address','$image')"; mysql_query($query); ?> <br> <? echo($query); mysql_close(); ?> the form <form action="insert.php"> bedrooms: <input type="text" name="bedrooms"><br> bathrooms: <input type="text" name="bathrooms"><br> area: <input type="text" name="area"><br> postcode: <input type="text" name="postcode"><br> ref: <input type="text" name="ref"><br> description:<input type="text" name="description"><br> rent pw: <input type="text" name="rentpw"><br> rentpm: <input type="text" name="rentpm"><br> deposit: <input type="text" name="deposit"><br> availability: <input type="text" name="availability"><br> type: <input type="text" name="type"><br> address: <input type="text" name="address"><br> image: <input type="text" name="image"><br> <input type="submit" method="post"> </form> all im getting is INSERT INTO lettings VALUES ('','','','','','','','','','','','','','','')
  11. wow, thats annoying. wish i wasnt with UK2 they take like 3 hours to say "we're looking into it" thanks for your help
  12. echoes "form submitted" also its still telling me the query INSERT INTO lettings VALUES ('','','','','','','','','','','','','','','') after going into PHPMyAdmin i noticed it does insert the data, but obviously the fields are left blank
  13. had to echo($_POST) as print_r has been disable for some security reason.. does this make a difference? It just says "Array"
  14. well yeah obviously but i cant see anything wrong with the HTML and dreamweaver doesnt seem to have any objections to it.. as for what happens after submission i havent a clue about that.. aside from the previous typo's which were ammended i dont see anything wrong <form action="insert.php" method="post"> bedrooms: <input type="text" name="bedrooms"><br> bathrooms: <input type="text" name="bathrooms"><br> area: <input type="text" name="area"><br> postcode: <input type="text" name="postcode"><br> ref: <input type="text" name="ref"><br> description:<input type="text" name="description"><br> rent pw: <input type="text" name="rentpw"><br> rentpm: <input type="text" name="rentpm"><br> deposit: <input type="text" name="deposit"><br> availability: <input type="text" name="availability"><br> type: <input type="text" name="type"><br> address: <input type="text" name="address"><br> image: <input type="text" name="image"><br> <input type="Submit"> </form>
  15. hey peter im not the best person to reply to this post but nevermind.. just thought id give you my 2 cents <!– Edit Below 3 –> <?php query_posts(’cat=-10&showposts=8′); ?> in this section the category is -10 rather than just 10, yet the others arent. replace them all with 3 and make sure the - is gone maybe that'll work
  16. i honestly dont have the php knowledge to find the problem.. i've looked gone over and over it in dreamweaver trying to see something out of place buti got nothin..
  17. sorry i think i just read the last post.. like i said - long day INSERT INTO properties VALUES ('','','','','','','','','','','','','','','')
  18. still showing "success" but doing not entering anything.. im confused.
  19. a REAL long day.. didnt solve the problem though
  20. ah man its been a long day - well spotted.. i sorted that but still having the same problem
  21. after an exhausting post figuring out what was wrong and finally getting everything to work, its all gone downhill. all i tried to do was add more fields to the database table + the input page and now the thing aint working. can anyone spot where i've messed up? i get no errors but it doesnt insert the info. input page <form action="insert.php" method="post"> bedrooms: <input type="text" name="bedrooms"><br> bathrooms: <input type="text" name="bathrooms"><br> area: <input type="text" name="area"><br> postcode: <input type="text" name="postcode"><br> ref: <input type="text" name="ref"><br> description:<input type="text" name="description"></textarea><br> rent pw: <input type="text" name="rentpw"><br> rentpm: <input type="text" name="rentpm"><br> deposit: <input type="text" name="deposit"><br> availability: <input type="text" name="availability"><br> type: <input type="text" name=type"><br> address: <input type="text" name="address"><br> image: <input type="text" name="image"><br> <input type="Submit"> </form> insert.php <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die(mysql_error()); $bedrooms=$_POST['bedrooms']; $bathrooms=$_POST['bathrooms']; $area=$_POST['area']; $postcode=$_POST['postcode']; $ref=$_POST['refs']; $description=$_POST['description']; $rentpw=$_POST['rentpw']; $rentpm=$_POST['rentpm']; $deposit=$_POST['deposit']; $propertynear=$_POST['propertynear']; $availability=$_POST['availability']; $type=$_POST['type']; $address=$_POST['address']; $image=$_POST['image']; $query = "INSERT INTO properties VALUES ('','$bedrooms','$bathrooms','$area','$postcode','$ref','$description','$rentpw','$rentpm','$deposit','$propertynear','$availability,'$type','$address','$image')"; mysql_query($query); echo("Success."); mysql_close(); ?>
  22. Well i appreciate it alot thanks man. considering i only started trying to learn php yesterday (and hadn't a clue about MySQL) its fair to say i would never have done it without ya premiso: "helping is for newbs" Wow i bet that makes ngreenwood feel real appreciated, great speech. this post has been going for over a day how long have been waiting to say that? If you really wana inspire people to donate, try be a little more tactful. Calling the people who DO help out newbs will just piss them off, which really will make the site disappear.
  23. AHA! We're up and running!! Thanks alot man! I did change the post method when you mentioned it but i edited the online version through my ftp client.. the one i zipped was my old local copy.. sorry i can be dumb sometimes lol. You've been a brilliant help thanks so much.. anyone else woulda started charging for their time by now lol
×
×
  • 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.