Hi, I’m about to build a website where people can upload items for sale and have run into a few problems.
I’ll try to be as specific as possible;
I have a problem with the search field where I previously have been able to combine the search field with the belonging category for the product. If you would leave the search field blank (keywords) and specify the category (drop-down menu) the result would show everything that has been registered to that category and vice versa. If you leave the category menu unspecified and type a keyword the you’d find result with that keyword in every category. Leave all empty and it shows all uploaded ads.
This is what my code looks like [php]
<?php $search = $_GET["search"]; $cat = $_GET["cat"]; $city = $_GET["city"]; if($search!="" &&$cat=="0") $sql = "SELECT tblad.*, category.catName FROM tblad INNER JOIN category ON category.catID=category.catID WHERE Object LIKE '%$search%' ORDER BY DateTime DESC"; if($search!="" &&$cat!="0") $sql = "SELECT tblad.*, category.catName FROM tblad INNER JOIN category ON tblad.catID=category.catID WHERE Object LIKE '%$search%' AND tblad.catID=$cat ORDER BY DateTime DESC"; if($search=="" && ($cat!="0"&&$cat!="")) $sql = "SELECT tblad.*, category.catName FROM tblad INNER JOIN category ON tblad.catID=category.catID WHERE tblad.catID=$cat ORDER BY DateTime DESC"; if($sql =="") $sql = "SELECT tblad.*, category.catName FROM tblad INNER JOIN category ON tblad.catID=category.catID ORDER BY DateTime DESC LIMIT 90"; echo ""; echo "
";[/php] Afterwards I realised I wanted people to be able to specify where they live, city wise. I chose to create a table in the db that i named city. I later created cityID and cityName within that table. In this way I want people to be able to search geographically. Now to the problem at hand: How would I go about to insert a third search choice (drop-down menu for cities containing the names) into the searching section. How would I make these three independent of each other but at the same time dependent so that the results could get either narrower or broader. I'm thinking in such a manner as it has been done previously but at that time with 2 search choices (keyword search and category drop down). When results are showing, I've come in to a problem where under the city results the cityID is showing instead of cityName and I keep getting errors when I try to write the cityName as echo. I think this will go away when I know more about how to fetch the information from the problem above, but it could be of interest to know about this now. To problem number 969:P: Uploading a picture to an ad. It refuses to show. I'm unsure if this is because of where the pictures are save or if the error is within the code. When I fill in everything, choose a picture and submit i get the following error: ""Array ( [filFile] => Array ( [name] => 649.jpg [type] => image/jpeg [tmp_name] => /Applications/XAMPP/xamppfiles/temp/phpCt1GKN [error] => 0 [size] => 9013 ) ) [u]Your ad was successfully uploaded! Click [b]here[/b] to take a look at it""[/u] The underlined is what is echoed if everything goes according to plan. And it does go according to plan if I check the database, just that the picture isn't saved/showing(its a question mark) or alternatively going somewhere I don't know (i specified the location as "pics/". Also I have no idea where "/Applications/XAMPP/xamppfiles/temp/" comes from. I've tried typing that directory as a destination but without any luck. I have no problem uploading whatever the community requires in order to get as good overview of the problem as possible. I would however love to have someone more experience in PHP to skype-textchat with in real time about problems since this is something I'm really starting to take huge interest in! I've been at this for some time now and I'm not getting any wiser :( Have a great one, ModiPad