Jump to content

usman07

Members
  • Posts

    310
  • Joined

  • Last visited

    Never

Everything posted by usman07

  1. Adding the escaped quotations makes my image disappear a blue sqaure question mark appears. this is what I have: echo "<a href=\'{$row['url']}\'><img class='image1' src=\'{$row['image_path']}\' alt=\'{$row['summary']}\'> </a> <br />";
  2. Thats to weird, I added the quotation marks: "<a href='{$row['url']}'><img class='image1' src='{$row['image_path']}' alt='{$row['summary']}'> </a> <br />"; I can see that the image is now a link but it just doesn't take me to the page that its meant to with the link in the database.
  3. I have done this, and the page appears and when I place the cursor over the image a hand appears so it shows the image being a link, but now when I click the image, it comes up with this: echo "<a href={$row['url']}><img class='image1' src='{$row['image_path']}' alt='{$row['summary']}'> </a> <br />"; but now when I click the image, it comes up with the message 'There was a problem etc...' from this code below. } else{ echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again";
  4. So now I have a url field in the images table, yeah the id is auto_increment.
  5. Could I put property id? because each property has its own unique id?
  6. but in my catagories i have types of property 'house' 'flat' There a image here showing you.
  7. here is a screenshot of my database: So here is the 'images' table, Could I add a field called 'url' or something then add the url in that field then somehow code it in php?
  8. here is a screenshot of my database: So here is the 'images' table, Could I add a field called 'url' or something then add the url in that field then somehow code it in php?
  9. Thanks for your assistance. Im a little bit confused, so do I create a field in my mySQL database and place the 'id' and the link then do the code you said? echo '<a href="xxxx.com/category.php?cat='.$row['cat_id'].'"><img class="image1" src="'.$row['image_path'].' alt='.$row['summary'].'></a><br />'; } What would I put in "xxxx.com" because the links are going to all be different depending on which image is displayed.
  10. Just another thing, I don't want the links to be displayed on the page, I just want the images to be links, so if the users click a image it will take them to another page.
  11. Oh ok mate, i will give it a try and see what happens, here what i have: <?php GET the id define('__HOST', ''); //localhost = database host name (normaly this won't need changing) define('__USER', ''); //xxx = database username define('__PASS', ''); //xxx = database password define('__DEF_DB', ''); //xxx = database name query db for that paticular id display the results ?>
  12. Thanks mate, where would the link be placed, for each image, in the database?
  13. So this will let me add different links on the different images of the properties? Because I don't want anything to be displayed, Once the search results are displayed depending on the search made, I want the images to have their own unique links that will take them directly to the selected property page.
  14. Hi mate, I dont know much about PHP coding, could you break a down a little more? appreciate it.
  15. That will just have the same link on all the results, but I need the different images to have different links?
  16. I mean when the results are displayed, they all will be different results on different properties. I have 9 properties on the website, therefore each property will have its own unique link to take them directly to the page that displays more information about the property.
  17. I basically have a PHP Search Form, and when a user fills in a form it outputs the results. Each result displays a image of a property, how could i make them images have their own unique link which will take them directly to the page of the property being shown? Im using PHP and mySQL tables Any help is appreciated, Thank You. Heres the PHP that outputs the results: <?php require_once 'mstr_ref.php'; function san($input){ if(get_magic_quotes_gpc()){ $input=stripcslashes($input); } $output = mysql_real_escape_string($input); return $output; } if(isset($_POST['submit'])){ $pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']); foreach ($pVars as $k=>$v){ $v = san($v); } $sql = new makeQuery(); $sql->manAdd('location_id', $pVars['area']); if($pVars['propType'] != 'Any'){ $sql->manAdd('catagory_id', $pVars['propType']); } if ($pVars['maxB'] > 0){ $sql->manAdd('bedrooms', $pVars['maxB'], '<='); } if($pVars['minB'] > 0){ $sql->manAdd('bedrooms',$pVars['minB'],'>='); } if($pVars['saleType'] != 'Any'){ if($pVars['saleType'] == "forsale"){ $sql->manAdd('market_type', 'sale'); if($pVars['minP'] != 0){ $pVars['minP'] = $pVars['minP'] * 1000; } if($pVars['maxP'] != 0){ $pVars['maxP'] = $pVars['maxP'] * 1000; } } if($pVars['saleType'] == 'forrent'){ $sql->manAdd('market_type', 'rent'); } } $qry = $sql->sqlStart.$sql->stmt.'Group By property.id'; $results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry"); if(mysql_num_rows($results) < 1){ die ("Sorry, No Results Match Your Search."); } while($row = mysql_fetch_assoc($results)){ echo '<div class="container" style="float:left;">'; echo '<div class="imageholder" style="float:left;">'; echo "<img class='image1' src='{$row['image_path']}' alt='{$row['summary']}'> <br />"; echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:14px; float:left; padding-top:10px;">'; echo "{$row['summary']}"; echo "<span style=\"color:#63be21;\"><br><br><b>{$row['bedrooms']} bedroom(s) {$row['bathrooms']} bathroom(s) {$row['receptions']} reception room(s)</b></span>"; if($row['parking'] != null){ echo "<span style=\"color:#63be21;\"><b> {$row['parking']} parking space(s)</b></span>"; } echo '</div>'; echo '<div style="clear:both"></div>'; } } else{ echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again"; } ?>
  18. I basically have a search form, and what I want is if the user selects 'For Sale' radial button then the minimum and maximum prices will start from £50,000 to £350,000 but if the users selects 'To Rent' then the minimum and maximum prices will change to 100 PCM to 400 PCM. any help would be appreciated. A image is attached of the form. Heres the PHP code for the search form: <form action="insert.php" method="post"> <table id="tb1"> <tr> <td><p class="LOC">Location:</p></td> <td><div id="LC"> <?php $locationSql = "SELECT id, area_name FROM locations GROUP by area_name"; $locQry = mysql_query($locationSql) or die (mysql_error()); echo "<select name=\"areas\" size=\"5\" style=\"width:150px;\">"; while ($location = mysql_fetch_assoc($locQry)){ echo "<option value=\"{$location['id']}\">{$location['area_name']}</option>"; } echo "</select>"; ?> </div> </td><td><p class="PT">Property type:</p></td> <td><div id="PS"> <?php $catSql = "SELECT id, cat_name FROM catagorys GROUP by cat_name"; $catQry = mysql_query($catSql) or die (mysql_error()); echo "<select name=\"prop_type\" size\"=5\" style=\"width:150px;\">"; while ($cat = mysql_fetch_assoc($catQry)){ echo "<option value=\"{$cat['id']}\">{$cat['cat_name']}</option>"; } echo "</select>"; ?> </div> </td> <td> <div id="ptype"> <input type="radio" class="styled" name="ptype" value="forsale"/> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent"/> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any" checked="checked"/> Any </p> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td><div id="NB"> <select name="min_bedrooms"> <?php $roomLimit = 5; for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){ if ($minRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minRooms\">$minRooms</option>"; } } ?> </select> to <select name="max_bedrooms"> <?php $roomLimit = 5; for($maxRooms = 0; $maxRooms <= $roomLimit; $maxRooms++){ if ($maxRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxRooms\">$maxRooms</option>"; } } ?> </select> </div> </td> <td><p class="PR">Price range:</p></td> <td><div id="PR"> <select name="min_price" style='width:80px;'> <?php $priceLimit = 350; for($minPrice = 40; $minPrice <= $priceLimit; $minPrice =( $minPrice+ 10)){ if ($minPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minPrice\">£$minPrice,000</option>"; } } ?> </select> to <select name="max_price" style='width:80px;'> <?php $priceLimit = 350; for($maxPrice = 40; $maxPrice <= $priceLimit; $maxPrice =( $maxPrice+ 10)){ if ($maxPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxPrice\">£$maxPrice,000</option>"; } } ?> </select> </div> </td> </tr> </table> <div id="submit1"><input type="submit" name="submit" value="submit" /></div> </div> </form> Thanks in advance.
  19. Ok, the property type is fixed, but when i submit the search, nothing comes up. Is the file meant to have a extension of insert.php?
  20. Thanks so much, Iv just tested it and the entries on the search form for property type: are being entered but are blank, no text is shown. Also when I submit the search, nothing seems to be displayed. Have a try here: http://www.mumtazproperties.hostei.com/ Thanks Also. the index and insert files when I downloaded them were e.g. 'index.php.xhtml' I took the .xhtml extension of so it is 'index.php' should have I done that, or should I have left it to 'index.php.xhtml'?
  21. This is my insert.php file code: <?php die(var_dump($_POST)); if ($debug) { // a variable I set at script top for debugging ;-) echo "<!-- $sql -->"; } $server = ""; // Enter your MYSQL server name/address between quotes $username = ""; // Your MYSQL username between quotes $password = ""; // Your MYSQL password between quotes $database = ""; // Your MYSQL database between quotes $con = mysql_connect($server, $username, $password); // Connect to the database if(!$con) { die('Could not connect: ' . mysql_error()); } // If connection failed, stop and display error mysql_select_db($database, $con); // Select database to use // Query database $result = mysql_query("SELECT * FROM Properties"); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 10) { $error[] = "Search terms must be longer than 10 characters."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT simages, sLocation, sNumberofbedrooms, sdescription FROM Properties WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['images'])?"`simages` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['Location'])?"`sLocation` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['Number of bedrooms'])?"`snumberofbedrooms` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`simages` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `sLocation`"; // order by title. $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$i}: {$row['sLocation']}<br />{$row['sNumberofbedrooms']}<br />{$row['sbody']}<br /><br />"; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } if (!$result) { echo "Error running query:<br>"; trigger_error(mysql_error()); } elseif(!mysql_num_rows($result)) { // no records found by query. echo "No records found"; } else { $i = 0; echo '<div class="container" style="float:left;">'; while($row = mysql_fetch_array($result)) { // Loop through results $i++; echo '<div class="imageholder" style="float:left;">'; echo '<img class="image1" src="'. $row['images'] .'" />'; //image echo '</div>'; echo '<div class="textholder" style="font-family:helvetica; font-size:13px; float:left; padding-top:10px;">'; echo "<span style=\"color:green;\"><b>Displaying record $i<br>\n</b><br></span>"; echo "<b>" . $row['id'] . "</b><br>\n"; // Where 'id' is the column/field title in the database echo "Location: ". $row['Location'] . "<br>\n"; // Where 'location' is the column/field title in the database echo "Property Type: ". $row['Property_type'] . "<br>\n"; // as above echo "Bedrooms: ". $row['Number_of_bedrooms'] . "<br>\n"; // .. echo "Purchase Type: ". $row['Purchase_type'] . "<br>\n"; // .. echo "Price: ". $row['Price_range'] . "<br>\n"; // .. echo '</div>'; echo '<div style="clear:both"></div>'; } echo '</div>'; } mysql_close($con); // Close the connection to the database after results, not before. ?>
  22. How would I use javascript and Ajax?Thanks
  23. Basically I have a form and What I want it to do is when a user selects the 'For Sale' radio button the minimum and maximum prices will be displayed in the drop down list as "70,000"+ but when the user selects the 'To Rent' radial button then the minimum and maximum drop down list prices will change to e.g. "200"+. How would I do this? Heres my Code for the form: <div id="ptype"> <input type="radio" class="styled" name="ptype" value="forsale"/> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent"/> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any"/> Any </p> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td><div id="NB"> <select name="min bedrooms"> <?php $roomLimit = 5; for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){ if ($minRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minRooms\">$minRooms</option>"; } } ?> </select> to <select name="max bedrooms"> <?php $roomLimit = 5; for($maxRooms = 0; $maxRooms <= $roomLimit; $maxRooms++){ if ($maxRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxRooms\">$maxRooms</option>"; } } ?> </select> </div> </td> <td><p class="PR">Price range:</p></td> <td><div id="PR"> <select name="min price" style='width:80px;'> <?php $priceLimit = 350; for($minPrice = 40; $minPrice <= $priceLimit; $minPrice =( $minPrice+ 10)){ if ($minPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minPrice000\">£$minPrice,000</option>"; } } ?> </select> to <select name="max price" style='width:80px;'> <?php $priceLimit = 350; for($maxPrice = 40; $maxPrice <= $priceLimit; $maxPrice =( $maxPrice+ 10)){ if ($maxPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxPrice000\">£$maxPrice,000</option>"; } } ?> </select> Thanks in advance.
  24. My form: <div id="Psearch"><img src="cutouts/Homepage/psearch.png" alt=""/></div> <form action="insert.php" method="POST"> <table id="tb1"> <tr> <td><p class="LOC">Location:</p></td> <td><div id="LC"> <?php $locationSql = "SELECT id, area_name FROM locations GROUP by area_name"; $locQry = mysql_query($locationSql) or die (mysql_error()); echo "<select name=\"areas\" multiple=\"multiple\" size\"=5\" style=\"width:150px;\">"; while ($location = mysql_fetch_assoc($locQry)){ echo "<option value=\"{$location['id']}\">{$location['area_name']}</option>"; } echo "</select>"; ?> </div> </td><td><p class="PT">Property type:</p></td> <td><div id="PS"> <select name="property type" style="width: 170px;"> <option value="none" selected="selected">Any</option> <option value="Houses">Houses</option> <option value="Flats / Apartments">Flats / Apartments</option> </select> </div> </td><td> <div id="ptype"> <input type="radio" class="styled" name="ptype" value="forsale"/> For Sale <p class="increase"> <input type="radio" class="styled" name="ptype" value="forrent"/> To Rent </p> <p class="increase"> <input type="radio" class="styled" name="ptype" value="any"/> Any </p> </div> </td> </tr> </table> <div id="table2"> <table id="NBtable"> <tr> <td><p class="NBS">Number of bedrooms:</p></td> <td><div id="NB"> <select name="min bedrooms"> <?php $roomLimit = 5; for($minRooms = 0; $minRooms <= $roomLimit; $minRooms++){ if ($minRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minRooms\">$minRooms</option>"; } } ?> </select> to <select name="max bedrooms"> <?php $roomLimit = 5; for($maxRooms = 0; $maxRooms <= $roomLimit; $maxRooms++){ if ($maxRooms == 0){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxRooms\">$maxRooms</option>"; } } ?> </select> </div> </td> <td><p class="PR">Price range:</p></td> <td><div id="PR"> <select name="min price" style='width:80px;'> <?php $priceLimit = 350; for($minPrice = 40; $minPrice <= $priceLimit; $minPrice =( $minPrice+ 10)){ if ($minPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Min</option>"; } else{ echo "<option value=\"$minPrice000\">£$minPrice,000</option>"; } } ?> </select> to <select name="max price" style='width:80px;'> <?php $priceLimit = 350; for($maxPrice = 40; $maxPrice <= $priceLimit; $maxPrice =( $maxPrice+ 10)){ if ($maxPrice == 40){ echo"<option value=\"0\" selected=\"selected\">No Max</option>"; } else{ echo "<option value=\"$maxPrice000\">£$maxPrice,000</option>"; } } ?> </select> </div> </td> </tr> </table>
×
×
  • 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.