Jump to content


  • Posts

  • Joined

  • Last visited

Skittle's Achievements


Member (2/5)



  1. Um okay very helpful information but it doesnt answer my question
  2. Hi, So I am currently making a real estate site for my class at school but I am having a tiny issue with the listing display page. So what I want to do is show a bunch of listing that the agent owns on their dashboard which I have already done. Now I have two links one to update the listing and one to view the listing. Now what I am trying to do is when the view listing link is clicked it will take the user to the listing-display page and then I want it to display all the information for the listing that the link was clicked under. But i cannot for the life of me figure out how to do that! This is currently the code for the dashboard where you only view the listing headline <?php // If the session was never set with a user id $output = ''; $conn = db_connect(); if($_SESSION['userType'] != AGENT) { $_SESSION['RedirectError'] = "You were not logged in as an Agent<br/>"; header("Location:login.php"); } if (isset($_GET["page"])) { $page = $_GET["page"]; $index = ($page -1) * IMAGE_LIMIT; } else { $page=1; $index = 0; } ?> <!-- start of main page content --> <div class="container" style="margin-top: 2em;"> <h2>Dashboard</h2> <p>Welcome back <?php echo $_SESSION['userId']; ?> you last logged in on <?php echo $_SESSION['last_access']; ?></p> <h4>Your Listings</h4> <?php $sql = "SELECT listing_id FROM listings WHERE user_id = '".$_SESSION['userId']."' AND status = 'o' ORDER BY listing_id"; $result = pg_query($conn, $sql); $listings = pg_fetch_all($result); for($index; $index < pg_num_rows($result); $index++) { $sql = "SELECT * FROM listings WHERE listing_id = '".$listings[$index]['listing_id']."'"; $listing_result = pg_query($conn, $sql); $arrayRow = pg_fetch_assoc($listing_result); echo (build_listing_card($arrayRow)); if($index !=0 && ($index +1) % IMAGE_LIMIT ==0){ break; } } ?> </div> <br/> <?php $total_pages = ceil(count($listings) / IMAGE_LIMIT); $pageLink = "<div class='pagination'>"; for ($i=1; $i<=$total_pages; $i++) { if($i == $page) { $pageLink .= "<a class='active' href='dashboard.php?page=".$i."'>".$i."</a>"; } else { $pageLink .= "<a href='dashboard.php?page=".$i."'>".$i."</a>"; } }; ?> </div> <br/> and this is the code for the listing-display page where I want all the listing information to be displayed <?php if (isset($_GET['listing_id'])) { $_SESSION['listing_id'] = $_GET['listing_id']; } else { $_SESSION['listing_id'] = 0; echo "ERROR: listing information was not find"; } $sql = 'SELECT * FROM listings WHERE listing_id = ' . $_SESSION['listing_id']; echo "<BR>".$sql; $result = pg_query(db_connect(), $sql); $records = pg_num_rows($result); echo "<BR>".pg_fetch_result($result, 0, "listing_id"); echo "<BR>".pg_fetch_result($result, 0, "user_id"); echo "<BR>".pg_fetch_result($result, 0, "status"); echo "<BR>".pg_fetch_result($result, 0, "price"); echo "<BR>".pg_fetch_result($result, 0, "headline"); echo "<BR>".pg_fetch_result($result, 0, "description"); echo "<BR>".pg_fetch_result($result, 0, "postal_code"); echo "<BR>".pg_fetch_result($result, 0, "images"); echo "<BR>".pg_fetch_result($result, 0, "city"); echo "<BR>".pg_fetch_result($result, 0, "property_options"); echo "<BR>".pg_fetch_result($result, 0, "bedrooms"); echo "<BR>".pg_fetch_result($result, 0, "bathrooms"); echo "<BR>".pg_fetch_result($result, 0, "garage"); echo "<BR>".pg_fetch_result($result, 0, "purchase_type"); echo "<BR>".pg_fetch_result($result, 0, "property_type"); echo "<BR>".pg_fetch_result($result, 0, "finished_basement"); echo "<BR>".pg_fetch_result($result, 0, "open_house"); echo "<BR>".pg_fetch_result($result, 0, "schools"); ?> <h1> Listing Display </h1> <hr/> <table style="width:50%" border="1px solid black"> <tr> <th>Listing Image</th> <th>Listing Description</th> </tr> <tr> <th rowspan="2"> <img src="" alt="Oshawa House" width="300px" height="200px"/> </th> <td align="left" valign="top"> <h3><?php echo pg_fetch_result($result, 0, "headline") ?></h3> <ul> <li>Open house?: <?php echo get_property('open_house', pg_fetch_result($result, 0, "open_house"))?> </li> <li>Finished Basement?: <?php echo get_property('finished_basement', pg_fetch_result($result, 0, "finished_basement"))?></li> <li><?php echo get_property('purchase_type', pg_fetch_result($result, 0, "purchase_type"))?></li> <li>Garage Type: <?php echo get_property('garage_type', pg_fetch_result($result, 0, "garage"))?></li> <li>Near school?: <?php echo get_property('schools', pg_fetch_result($result, 0, "schools"))?></li> <li>Status: <?php echo get_property('listing_status', strtolower(pg_fetch_result($result, 0, "status"))) ?></li> <li>Washrooms: <?php echo get_property('washrooms',pg_fetch_result($result, 0, "bathrooms")) ?></li> <li>Bedrooms: <?php echo get_property('bedrooms',pg_fetch_result($result, 0, "bedrooms")) ?></li> <li>Description: <?php echo pg_fetch_result($result, 0, "description") ?></li> </ul> </td> </tr> <tr> <td align="left" valign="top"><ul> <li>Location: <?php echo get_property('cities',pg_fetch_result($result, 0, "city")) ?></li> <li>Postal Code: <?php echo pg_fetch_result($result, 0, "postal_code") ?></li> <li>Price: <?php echo pg_fetch_result($result, 0, "price") ?></li> </ul> </td> </tr> </table> <form action="listing-matches.php"> <p> <input type="submit" name="submit" value="Back"/></p> </form>
  3. ah yes right! That worked and my issues haave been resolved thanks!
  4. if i take out the $minPrice = ""; yes it stays populated but I'm still getting the error message all I want to do is not to get that error message and execute the next part of my code. I changed the preg_match stuff to elseif(is_numeric($minPrice)) instead
  5. This is for a class assignment technically I am just starting out but I am also on my second year of school, I've been working on this page for a week and still having these issues that's why I came here for help and the error message I am getting is the price needs to be a number so I will take a look at that manual thank you very much also the headline is now fixed to so that is good
  6. Oh wow I didnt even notice that, no I don't know how to change that, but that still doesnt fix why minprice automatically goes blank too
  7. Im dumb GET = Array ( ) POST = Array ( [newlist] => house for sale [city] => oshawa [minPrice] => 100 [maxPrice] => 1000 ) thisis what I get
  8. GET = Array ( ) { } POST = Array ( ) { } This is all i get when I put that in
  9. Yeah trying to figure out those errors, its been a long frustrating process
  10. Warning: A non-numeric value encountered in /var/www/html/webd3201/group07/includes/functions.php on line 51 Notice: Undefined index: userType in /var/www/html/webd3201/group07/header.php on line 59 Notice: Undefined index: userId in /var/www/html/webd3201/group07/header.php on line 15 A bunch of lines of these three errors
  11. I have used those by the way but it does not tell me why I am having this one particular issue
  12. I've been working on this html/php page for class and I just don't understand why my code is acting like this. I have this form that gets the user input and then it validates the code with appropriate error messages but even when I test it and type in something for each textbox it automatically makes the textbox go blank again and displays the error messages and i dont know why. This is my code <?php //error_reporting(E_ALL); //ini_set('display_errors', 1); $title = "Listing Search"; $file = "listing-search.php"; $description = "Listing Search page for real estate website (WEBD3201)"; $date = "2019-10-01"; $banner = "Listing Search page"; require "header.php"; ?> <?php $headline = ""; $minPrice = ""; $maxPrice = ""; $city = ""; $error = ""; $output = ""; $error = ""; $output = ""; if(isset($_GET["city"])) { $city = $_GET["city"]; setcookie('city',$city,COOKIE_LIFESPAN); $_SESSION['city'] = $city; } else if (isset($_COOKIE['city'])) { $city = $_COOKIE['city']; $_SESSION['city'] = $city; } if(!isset($city)) { $_SESSION['RedirectError'] = "Please select a city<br/>"; header("Location:listing-select-city.php"); } if(isPost()) { $minPrice = trim($_POST["minPrice"]); $output .=$_POST["minPrice"]; $maxPrice = trim($_POST["maxPrice"]); $output .=$_POST["maxPrice"]; $headline = trim($_POST["headline"]); $output .=$_POST["headline"]; $city = trim($_POST["city"]); $output .=$_POST["city"]; $error = ""; $output = ""; if($headline == "") { $error .= "<br/>Headline was not specified"; } if($city == "") { $error .= "<br/>City was not specified"; } if($minPrice == "") { $error .= "<br/>Minimum price was not specified"; } elseif (preg_match(PRICE_FILTER, $minPrice) == '0') { $error .= "<br/>Minimum price needs to be a number"; $minPrice = ""; } if($maxPrice == "") { $error .= "<br/>Maximum price was not specified"; } elseif (preg_match(PRICE_FILTER, $maxPrice) == '0') { $error .= "<br/>Maximum price needs to be a number"; $minPrice = ""; } if($maxPrice < $minPrice) { $error .= "<br/>Minimum price must be smaller than maximum price"; } } ?> <?php echo $error; ?> <?php echo $output;?> <h2>Search for a home.</h2> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table style="margin-left: auto; margin-right: auto;"> <tr> <td> Listing Name </td> <td> <input type="text" name="newlist" value="<?php echo $headline ?>" /> </td> <td> City </td> <td> <input type="text" name="city" value="<?php echo $city ?>" /> </td> </tr> <tr> <td> Min Price </td> <td> <input type="text" name="minPrice" value="<?php echo $minPrice ?>" /> </td> <td> Max Price </td> <td> <input type="text" name="maxPrice" value="<?php echo $maxPrice ?>" /> </td> </tr> </table> <table style="margin-left: auto; margin-right: auto;"> <tr> <td> <input type="submit" value = "Search" /> </td> <td> <input type="reset" value = "Clear" /> </td> </tr> <tr> <td> <?php echo build_checkbox("internet", "DSL"); ?> </td> <td> <?php echo build_checkbox("heating", ""); ?> </td> </tr> </table> </form> <?php require "footer.php"; ?>
  • 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.