Jump to content

Drummin

Members
  • Posts

    1,004
  • Joined

  • Last visited

Everything posted by Drummin

  1. That print must be an html table not the DB table. What does the DB table look like when doing a clean update,i.e. closing browser and reloading fresh copy of the page and posting your form again. Does new DB values match?
  2. On the off chance are you entering into the form a plain text password, where it's matching m5() value is in the table? Or do you have a plain text password stored to DB?
  3. Assuming that the $_POST['prodid'] count is really WHAT you want to be using for loop ending value, moving the end loop tag so it surrounds the insert should fix the problem. Note: what you had commented as the closing loop was the end of the function loop. <?php function finishedorder(){ $prodname = $_POST['prodname']; $prodid =$_POST['prodid']; $quantity = $_POST['quantity']; $pricelb = $_POST['pricelb']; $customerid = $_POST['customerid']; $price = $_POST['price']; $orderid = $_POST['orderid']; $weight = $_POST['weight']; echo "Varuable WEight"; print_r($weight); echo"<br/>"; echo "line 196 Weight"; print_r ($_POST['weight']); echo"<br/>"; echo "line 192 PriceLB"; print_r ($_POST['pricelb']); echo "<br/>"; echo "line 193 Price"; print_r ($_POST['price']); echo "<br/>"; echo "line 194 ProdID"; print_r ($_POST['prodid']); echo "<br/>"; echo "line 195 OrderID"; print_r ($_POST['orderid']); echo "<br/><br/>"; $numloops = count($_POST['prodid']); for ($i = 0; $i < $numloops ; $i++) { // !!! Start of the for loop !!! if (!isset($orderid[$i])) $orderid[$i] =''; if (!isset($prodid[$i])) $prodid[$i] =''; if (!isset($weight[$i])) $weight[$i] =''; if (!isset($pricelb[$i])) $pricelb[$i] =''; // This only initialises the Price & Weight variable to avoid an offset error message. if (!isset($weight[$i])) $weight[$i] =''; $ordervalue = $pricelb[$i] * $weight[$i]; echo " L. 216 The number is " . $i . "<br />"; echo "line 221 ProdID".$prodid[$i];echo "<br/>"; echo "line 217 Pricelb".$pricelb[$i];echo "<br/>"; echo 'Weight L. 219 weight[i]'. $weight[$i];echo "<br/>"; echo "line 220 weight".$weight; echo "<br/>"; echo "line 221 Numloops".$numloops; echo "<br/><br/>"; echo ' L. 225 $ordervalue ' .$ordervalue;echo "<br/>"; //if ($pricelb[$i] == 0 ){ // conditonal statement // $ordervalue = $price[$i]; // } $sql =" UPDATE confirmedorder SET weight='$weight[$i]', ordervalue='$ordervalue', confirmedorder.picking = 'finished', confirmedorder.sale = 'open' WHERE prodID = '$prodid[$i]' AND OrderID = '$orderid[$i]' ; "; $this->db->query($sql); } // !! End For Loop. !! } ?>
  4. What needs to be understood is how information is being gathered on this page. From what can see you have several instances of the array $something and all we're doing is adding these to one array called $result_array. Of course if the page reloads this all goes away. So what do you expect to happen and how is the information coming to the page.
  5. I was talking about your results page not the form. I know you started with mysql and see you still have it in your form, but when last seen, your results page used PDO formatting. This is why I added $sql->manAdd('type', $_GET['type']); in my last post with code as I had assumed you had moved to this format. Do as I suggested making a page (in your current format) and then we can see about the filter.
  6. How did you end up doing your query on the results page? Basically you're doing the same thing, where your baseline "where condition" is looking for field_name='for_sale' or something along those lines. All you're going to do is add the extra filter condition AND type = '{$_GET['type']}' only I wouldn't do this directly in the query line. I would suggest getting you basic query and display section working, then we'll see about adding the filter.
  7. Right not mail() in not inside query results loop OR the FOR() loop you've made so only the last instance of the variable $email would be available. I see no reason to build an array here. while($row=mysql_fetch_assoc($res)) { $contents=""; $contents=" <a href='http://www.example.com/bulkEmail/thankyou.php?email=".$row['email']."'>click here to join</a> <br/> "; // Add DB INSERT CODE HERE IF SAVING TO DB //CONTINUE WITH EMAIL CODE Headers etc. }//Closing while loop
  8. So what's your query setup for getting properties forsale on this page? I see again you have an html extension, where it should php for pages that use php. It looked and sounded like you wanted a secondary filter process after the form. As this I gather is on a new page other than the search form results page then disregard my other posts I made regarding this topic. Please make sure you are clear in explaining what is happening or show code you are using. Again, as I don't see code, I will just give you some code regarding adding the filter. You've used similar coding in your other pages so you should have this down by now. You are just checking for get, making sure get is valid by comparing to allowed values, then adding the filter to your query. $sql = new makeQuery(); $ftypes=array("Detached","Semi-detached","Terraced","Flats"); if (isset($_GET['type']) && in_array("{$_GET['type']}",$ftypes)){ $sql->manAdd('type', $_GET['type']); } //Continue with rest of query and display
  9. Hmm My code gives me <p>I decided to start my own business because I want <br /> to be my own boss! </p> <p>My boss is a jerk and never appreciates anything <br /> that I do for him, so why put up with the abuse?! <br /> He takes me for granted and doesn't appreciate <br /> all of my talents. </p> <p>Running my own business will give me a chance <br /> to do things as I see fit...</p> Barand's code give me <p>I decided to start my own business because I want<br /> to be my own boss!<br /> <br /> My boss is a jerk and never appreciates anything<br /> that I do for him, so why put up with the abuse?!<br /> He takes me for granted and doesn't appreciate<br /> all of my talents.<br /> <br /> Running my own business will give me a chance<br /> to do things as I see fit...</p>
  10. Then you should be storing the actual email of the person. Assuming this is being executed in a loop where the variable $email is set as in when sending the email message. $message =" <a href='http://www.example.com/thankyou.php?email=".$email."'>click here to join</a> "; $message=mysql_real_escape_string($message); //Do your insert query here into DB message='{$message}' //Change to a real query storing the variable $message.
  11. 1. Are wanting literal message saved that was sent, e.g. <a href='http://www.example.com/[email protected]'>click here to join</a> 2. Or the variable $email <a href='http://www.example.com/thankyou.php?email=".$email."'>click here to join</a>
  12. You just need to check if $result_array isset and if NOT, set it, otherwise you are changing it back to empty when the script is run again. <?php if (!isset($result_array)){ $result_array = array(); } //Add one link $something = array('Link1'); foreach($something as $links) { //I will assume this is a function you are using so left in place // $url_links = get_links_from_site($links); // ignore this.This is only supposed code which get links. $url_links = $links; $result_array[] = $url_links; } //add another link if (!isset($result_array)){ $result_array = array(); } $something = array('Link2'); foreach($something as $links) { //I will assume this is a function you are using so left in place // $url_links = get_links_from_site($links); // ignore this.This is only supposed code which get links. $url_links = $links; $result_array[] = $url_links; } //let's add two more if (!isset($result_array)){ $result_array = array(); } $something = array('Link3','Link4'); foreach($something as $links) { //I will assume this is a function you are using so left in place // $url_links = get_links_from_site($links); // ignore this.This is only supposed code which get links. $url_links = $links; $result_array[] = $url_links; } //and two more again if (!isset($result_array)){ $result_array = array(); } $something = array('Link5','Link6'); foreach($something as $links) { //I will assume this is a function you are using so left in place // $url_links = get_links_from_site($links); // ignore this.This is only supposed code which get links. $url_links = $links; $result_array[] = $url_links; } //and one more if (!isset($result_array)){ $result_array = array(); } $something = array('Link7'); foreach($something as $links) { //I will assume this is a function you are using so left in place // $url_links = get_links_from_site($links); // ignore this.This is only supposed code which get links. $url_links = $links; $result_array[] = $url_links; } echo "<pre>"; print_r($result_array); echo "</pre>"; ?>
  13. I don't see a copy of you current insert.php page but it started something like this. Adjust as needed. As I recall you wanted to use $_GET['type'] as your extra filter. <?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; } session_start(); //IF post or get type if(isset($_POST['submit']) || isset($_GET['type'])){ //if isset post set to session if (isset($_POST['submit'])){ $_SESSION['current_filter']=$_POST; $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']); } //if isset get type and isset session, build same array using session values adding new get type if (isset($_GET['type']) && isset($_SESSION['current_filter'])){ $pVars = array('area'=>$_SESSION['current_filter']['areas'], 'propType'=>$_SESSION['current_filter']['prop_type'], 'saleType'=>$_SESSION['current_filter']['ptype'], 'minB'=>$_SESSION['current_filter']['min_bedrooms'], 'maxB'=>$_SESSION['current_filter']['max_bedrooms'], 'minP'=>$_SESSION['current_filter']['min_price'], 'maxP'=>$_SESSION['current_filter']['max_price'], 'type'=>$_GET['type']); } //you then continued with... foreach ($pVars as $k=>$v){ $v = san($v); } $sql = new makeQuery(); $sql->manAdd('location_id', $pVars['area']); // Add the new search value if (isset($pVars['type'])){ $sql->manAdd('catagory_id', $pVars['type']); } //continue
  14. If possible, can some then please explain why I get single line breaks as <br /> and double breaks with <p></p> as shown below but Debbie does not. Is it a doctype issue? Server issue? Something else? <html> <body> <p>I decided to start my own business because I want <br /> to be my own boss! </p> <p>My boss is a jerk and never appreciates anything <br /> that I do for him, so why put up with the abuse?! <br /> He takes me for granted and doesn't appreciate <br /> all of my talents. </p> <p>Running my own business will give me a chance <br /> to do things as I see fit...</p></body> </html>
  15. Just thought I'd see what the big boys have to say about the example I offered. <?php $text="I decided to start my own business because I want to be my own boss! My boss is a jerk and never appreciates anything that I do for him, so why put up with the abuse?! He takes me for granted and doesn't appreciate all of my talents. Running my own business will give me a chance to do things as I see fit..."; function nl2p($text) { $text=str_replace("\n\r\n","</p>\r\r<p>","$text"); $text=str_replace("\n","<br /> ","$text"); $text="<p>" . $text . "</p>"; return($text); } echo nl2p($text); ?>
  16. See how this works. Untested. <html> <head> <title></title> </head> <body marginheight="0" topmargin="0" marginwidth="0" leftmargin="0" style="margin:0;padding:0" bgcolor="#B0E0E6"> <h1></h1> <form action="" method="post"> <?php @ $db = new mysqli('xxx', 'xxx', 'xxx', 'xxx'); $query = "call sp_view_all_venues();"; $result = $db->query($query); $num_results = $result->num_rows; function db_result_to_array($result){ //--------------------------------------------------------------------- $res_array = array(); for ($count=0; $row = $result->fetch_assoc(); $count++) { $res_array[$count]=$row; } return $res_array; } //--------------------------------------------------------------------- echo "<table>"; echo "<tr><td>"; echo "<input type='submit' id='btnupdate' name='btnupdate' value='Update & Delete' >"; echo "</td></tr>"; $irow=0; while($row = $result->fetch_assoc()) { if($row['venue1']==1) $checked=" checked='checked'"; else $checked=''; if($row['venue2']==1) $checked2=" checked='checked'"; else $checked2=''; echo "<tr><td>"; echo "<input type='radio' name='venue_id[".$row['venue_id']."]' value='1'".$checked."/>".$row['venue_id'].""; echo "<input type='radio' name='venue_id[".$row['venue_id']."]' value='0'".$checked2." />P2"; echo "</td></tr>"; $irow++; } echo "</table>"; echo "<pre>"; print_r($_POST); echo "</pre>"; ?> </form> </body> </html>
  17. What's your current insert.php file look like assuming this is still what you're calling your search results page. What you are going to want to do is grab the current POST values and save these to session if your display is directly from DB. If on the other hand, you are building an array from post/query that you then display, you can just filter the array based of these other values. In ether case the POST or array needs to be stored to session. However sessions are not meant to store volumes of data so saving the POST values, adding the extra filter option and re-querying the DB would be a better option. Hey just my opinion.
  18. Hello usman07, this has sure been a project huh. Keep in mind that you need to retain your current search perimeters when then adding these extra filters. I am not sure if you are building an array from the first POST filter or displaying directly from the query. One way or another those values need to be saved, probably to session, then apply your extra filters.
  19. Please see update, so variable $product_id is available regardless of GET or POST. if (isset($_GET['product_id']) || isset($_POST['product_id'])){ if (isset($_GET['product_id'])){ $product_id = $_GET['product_id']; } if (isset($_POST['product_id'])){ $product_id = $_POST['product_id']; }
  20. Well really, that whole section were you query DB table and show for should be wrapped in an IF statement as it relies on having the GET value. <?php //check to see if user is logged on session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != "")) { header ("Location:login.php"); } include('connect.php'); //connection details to database in a connect.php page //if form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST'){ //get values from fields $product_id = $_POST['product_id']; $productname = $_POST['pname']; $range = $_POST['prange']; $price1 = $_POST['pprice']; $price = (int)$price1; if (empty($productname) || empty($range) || empty($price)) { $errorMessage .= "Please fill in all text boxes"; } else { $errorMessage = ""; $query = "UPDATE products SET product_name = '$productname', product_range = '$range', product_price = '$price' WHERE product_id = '$product_id'"; $result = mysql_query($query); print "<br> $productname from range $range with a price of $price has been updated!"; } } if (isset($_GET['product_id']) || isset($_POST['product_id'])){ if (isset($_GET['product_id'])){ $product_id = $_GET['product_id']; } if (isset($_POST['product_id'])){ $product_id = $_POST['product_id']; } $query = "SELECT * FROM products WHERE product_id = '$product_id'"; $result = mysql_query($query); echo "<form method = \"post\" action = \"edit.php\">"; while($row = mysql_fetch_array($result)){ echo "<table>"; echo "<tr>"; echo "<td><input name = 'product_id' type = 'hidden' value ='{$row['product_id']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Name:</td><td><input name = 'pname' type = 'text' value ='{$row['product_name']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Range:</td><td><input name = 'prange' type = 'text' value ='{$row['product_range']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Price:</td><td><input name = 'pprice' type = 'text' value ='{$row['product_price']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td><input type = 'submit' name = 'Submit' value = 'Update'></td>"; echo "</tr>"; echo "</table>"; } echo "</form>"; }//if (isset($_GET['product_id'])) ?>
  21. Try to keep processing above display so updates will be reflected with page reloads. Avoid having anything sent to the browser if using a header() tag a before starting and updating sessions. Your for had action as GET put processing was POST. Missing </form> tag. See how this one works. <?php //check to see if user is logged on session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != "")) { header ("Location:login.php"); } include('connect.php'); //connection details to database in a connect.php page //if form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST'){ //get values from fields $product_id = $_POST['product_id']; $productname = $_POST['pname']; $range = $_POST['prange']; $price1 = $_POST['pprice']; $price = (int)$price1; if (empty($productname) || empty($range) || empty($price)) { $errorMessage .= "Please fill in all text boxes"; } else { $errorMessage = ""; $query = "UPDATE products SET product_name = '$productname', product_range = '$range', product_price = '$price' WHERE product_id = '$product_id'"; $result = mysql_query($query); print "<br> $productname from range $range with a price of $price has been updated!"; } } $product_id = $_GET['product_id']; $query = "SELECT * FROM products WHERE product_id = '$product_id'"; $result = mysql_query($query); echo "<form method = \"post\" action = \"edit.php\">"; while($row = mysql_fetch_array($result)){ echo "<table>"; echo "<tr>"; echo "<td><input name = 'product_id' type = 'hidden' value ='{$row['product_id']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Name:</td><td><input name = 'pname' type = 'text' value ='{$row['product_name']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Range:</td><td><input name = 'prange' type = 'text' value ='{$row['product_range']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td>Product Price:</td><td><input name = 'pprice' type = 'text' value ='{$row['product_price']}'></td>"; echo "</tr>"; echo "<tr>"; echo "<td><input type = 'submit' name = 'Submit' value = 'Update'></td>"; echo "</tr>"; echo "</table>"; } echo "</form>"; ?>
  22. Well right off the bat I see an echo and header in the same line. For headers to work they must be done before anything is sent to the browser. Rather than echo the line, set a variable, e.g. $message="whatever"; that you can then echo this down in your code below your <html> tags (which I don't see). Really, processing should be done above <html> and forms messages etc, displayed within the <body> tags.
  23. Not 100% without testing, but replace your foreach statement with this. foreach ($_POST as $key => $val) { if ($key!="submit"){ if ($key=="service"){ foreach ($_POST['service'] as $service) { $message .= "Service: " . clean($service) . "\r\n"; } }else{ $message .= ucwords($key) . ": " . clean($val) . "\r\n"; } } }
  24. On insert.php you'd do something like this. while($row = mysql_fetch_assoc($results)){ echo '<div class="container" style="float:left;">'; echo '<div class="imageholder" style="float:left;">'; echo "<a href=\"propertyinfo.php?id={$row['id']}\"><img class='image1' src=\"{$row['image_path']}\" alt=\"{$row['summary']}\"> </a> <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>"; } On propertyinfo.php you need to pick up this GET value and add it to your query. if (isset($_GET['id']) && is_numeric($_GET['id'])){ //Do your queries WHERE id='{$_GET['id']}' etc. Adjust for table field names e.g. property_id for images etc. Note: I have not downloaded current code so adjust as needed.
  25. I don't see how you are doing php on a page with an html extension. I also don't see anywhere where you've identified the property you are viewing. I suppose if you only have one record in the `images` table then it could call up the expected results but again running php on an html page is not the norm and I'm surprised you are seeing anything. My suggestion still stands as the best answer.
×
×
  • 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.