Jump to content

Mr Chris

Members
  • Posts

    336
  • Joined

  • Last visited

    Never

Everything posted by Mr Chris

  1. Thanks, yes it does, but not how I want it to. It then just emails each user in the table shown the full set of results for the query: $query_one = "SELECT * FROM property_weekly AS p, properties_wanted as pw WHERE p.address_4=pw.county AND p.town=pw.town AND p.bedrooms=pw.bedrooms ORDER BY pw.price DESC LIMIT 6"; I've tested it and I know if each property_id is changed in each query to the next row in the database automatically then the code I have written works great. It's just getting it to do that. Any other suggestions
  2. A lot of hosting companies offer Cron Jobs as their package in their control panel. Have a search through sitepoint http://www.sitepoint.com/forums/search.php?searchid=3476184 I know when I was looking for how to do this a while back I found the answer on a thread there. Alternatively you will probably find what you are looking for doing a search on php freaks.
  3. Hello, I was looking for some help. I have a table: and I wish to use that table to query another table. and then send an email out with the results of the query: <?php // Start the connection to the database // End the connection to the database $current_url = $_SERVER['SERVER_NAME']; $messagebody = "** This is an automated message - please do not reply **:\n\n Please find homes that match your criterian\n"; $query_one = "SELECT * FROM property_weekly AS p, properties_wanted as pw WHERE p.address_4=pw.county AND pw.property_id='1' AND p.town=pw.town AND p.bedrooms=pw.bedrooms ORDER BY pw.price DESC LIMIT 6"; $result = mysql_query($query_one) OR die(mysql_error()); while ($row = mysql_fetch_array($result)) { $messagebody .= stripslashes($row['address_1']) . "\n" . "http://$current_url/live/stories/story.php?prop_id=" . $row['prop_id'] . "\n\n"; } $query_two = "SELECT your_name, your_email FROM `properties_wanted` WHERE property_id = '1'"; $result = mysql_query($query_two) OR die(mysql_error()); $number_of_results = mysql_num_rows($result); If (mysql_num_rows($result) > 0) { echo "We have send the email out to <b>".$number_of_results."</b> registered users"; } else { $row = mysql_fetch_array( $result ); echo "Nobody has registered for email alerts"; } while ($row = mysql_fetch_array($result)) { $lines = "-------------------------------------------------------------------------------------------------------------\n"; $your_name = "Dear ". $row['your_name'] ."\n\n"; $unsubscribe = "To unsubscribe from this email alert please visit the link below:\n"; $messagelink = "http://$current_url/live/email_alerts/unsubscribe_email.php?email=". $row['your_email'] ."\n\n"; $message = $your_name.$messagebody.$lines.$unsubscribe.$messagelink; mail($row['your_email'], "Property Details", $message, "From: website@dasdasdassadda.co.uk"); } ?> Now in BOTH of my queries in the code you will see the condition Where property_id=1 and what I want to do is loop through the table shown for each row and modify the query. Ie so the next condition is the next property_id in the database ie:property_id=2 and keep on looping depending on the number of records. Can anyone help? Thanks
  4. First of all thanks for this. I've tried the code you posted and mine shows exactly the same. Here's a live link: http://www.slougheaz.org/section.php?sec=2&story_id=3167 Which should also read as: http://www.slougheaz.org/article/2/dream-ends-in-an-instant/ However I get an SQL error as I reply upon GET in my query: $result = mysql_query("Select * from cms_stories where story_id=".$_GET['story_id']); Is this where it's failing? Is there any way I can use GET and still have the URL like so? Or do I need a story_id in there? Thanks for all your help.
  5. Thanks a lot, But it's not quite there as it's not working as it's bringing up a 404 any other suggestions? I'd like it this format: http://www.mywebbysite22.org/section.php?sec=2&story_id=3250 replaced by this: http://www.mywebbysite22.org/article/2/man-walks-in-park/ with Man Walks in Park being the headine. Thanks
  6. Hi Guys, Say I have the headline: Man walks in Park Which is dynamically called from the database via a story_id like so: http://www.mywebbysite22.org/section.php?sec=2&story_id=3250 I'd like converted like so: http://www.mywebbysite22.org/article/2/man-walks-in-park/ So in my php code I added this line to convert the headline: $headline = $row['headline']; $clean_headline = str_replace(' ', '-', strtolower($headline)); and then tried to write this to .htaccess, but it does not work. I think i'm nearly there, but not quite: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteRule ^article/([0-9]+)/[^/]+-([0-9]+)\ $ section.php?s=$1&story_id=$2 [QSA,L] Can anyone help? Cheers
  7. Hi, Say I have a table named properties like so: and wanted to query it ie: Select * from Properties where house_type ='Maisonette' AND rent_or_buy = 'buy' That would be fine, but is there anyway in php to run a query like the above, but via another table ie: Look in this properties_wanted table and then loop through all the records asking it to Select * from Properties where house_type ='columnvalue' AND rent_or_buy = 'columnvalue' ? Thank you
  8. That's the one - thanks. Any links to this though?
  9. Thanks, but i'm getting an unxepected parse error: Parse error: syntax error, unexpected '.' on this line: $xx =. "<div class='number'>".$i."</div>"; // Output 'other pages' link for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ $xx =. "<div class='number'>".$i."</div>"; }else{ $xx =. "<div class='number'><a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a></div>"; } } //end for // Output 'first' image link if(($totalrows % $limit) != 0){ if($i == $page){ $xx =. "<div class='number'>".$i."</div>"; }else{ $xx =. "<div class='number'><a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a></div>"; } } //end if I've tried googling the error, but it won't search for .= Can anyone post any links that will help me understand this better?
  10. Thanks Guys, Here's the code for both: Assigning to variable <?php for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ $xx ="<div class='number'>".$i."</div>"; }else{ $xx ="<div class='number'><a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a></div>"; } } //end for if(($totalrows % $limit) != 0){ if($i == $page){ $xx ="<div class='number'>".$i."</div>"; }else{ $xx ="<div class='number'><a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a></div>"; } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <style> .number { float:left; display:inline; padding-top:4px; width:20px; height:20px; background:#0031AA; color:#FFFFFF; font-weight:bold; text-align: center; } </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php echo $xx; ?> </body> </html> and the result here which does not output properly: http://www.thisiswindsor.com/search/n.php Echoing out <?php for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo("<div class='number'>".$i."</div>"); }else{ echo("<div class='number'><a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a></div> "); } } //end for if(($totalrows % $limit) != 0){ if($i == $page){ echo("<div class='number'>".$i."</div>"); }else{ echo("<div class='number'><a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a></div> "); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <style> .number { float:left; display:inline; padding-top:4px; width:20px; height:20px; background:#0031AA; color:#FFFFFF; font-weight:bold; text-align: center; } </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php echo $xx; ?> </body> </html> and the result here which does not output properly: http://www.thisiswindsor.com/search/y.php Which works fine? Thanks
  11. Hi Guys, In my code I echo out the following code as links if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a> "); } Which works great But instead of echoing I want to assign the code to a variable: if($i == $page){ $paglinks = ($i." "); }else{ $paglinks = "<a href=\"$PHP_SELF?town=$town&from_price=$from_price&to_price=$to_price&bedrooms=$bedrooms&page=$i\">$i</a>"; } and then output it: <?php echo $paglinks; ?> But this does not seem to output properly? Any ideas?
  12. Doh, that does work! Please ignore me, thanks anyway!!
  13. Thanks, Just one more i'm stuck with on a condition check. If $bathroom is not empty and less than 4 otherwise use the other condition if(!empty($bathrooms) && $bathrooms < '4') { $add .= " AND bathrooms = '$bathrooms'"; } if(!empty($bathrooms) && $bathrooms > '5') { $add .= " AND bathrooms > '5'"; }
  14. Hi All, I have a very simple piece of condition checking that I’m having trouble with: I only want to use this condition IF $from_price OR $to_price is empty then don't add the below query: if(!empty($from_price) || ($to_price)) { $add .= " AND price BETWEEN '$from_price' AND '$to_price'"; } However, if $from_price has a value and $to_price does not it still outputs this condition (and vice versa). Can anyone help? Thanks
  15. Thanks. I wish I could. It would make life a lot easier but sadly it's not mine :-(
  16. Hi Guys, I’m working with a non-normalized database like so and in one column named related it holds some values it (it could have any amount) which I want to: - Grab hold of - Explode (on the comma) - Then run the query below for each entry in this column So for example it would take the word Preditor Game for story_id=103. Run the below query, hold the results found and then do the same again for the word alien etc… before eventually outputting the results found Now I know I can’t explode on my query as shown below, but that’s to kind of show what I’m trying to achieve. Is this possible? Thanks <?php $query = "SELECT DISTINCT story_id, headline, story, related FROM cfm_stories WHERE (headline LIKE '%(explode(',', $row['related'], -1))%' OR story LIKE '%(explode(',', $row['related'], -1))%') AND story_id != $story_id AND unix_timestamp(published) <= unix_timestamp(NOW()) ORDER BY unix_timestamp(published)asc"; $result = mysql_query($query) OR die(mysql_error()); $the_results = mysql_num_rows($result); if ($the_results == 0) { echo ("Sorry, there are no related stories"); } else { while($row = mysql_fetch_assoc($result)) { echo "<a href='story.php?story_id={$row[story_id]}'>'.$row[headline].'</a><br />"; } } ?>
  17. Hi Guys, Say In mysql database I have a field named details which holds all the paragraphs of a story: and these details are not held in the database as html, but there is a line gap inbetween the paragraph breaks. How can I output the first two paragraphs of this text, while also making the first paragraph outputted bold? Thank You Chris
  18. Thanks! Just one other thing. Now my condition checking is not working. It throws up $error even though you are uploading the correct extentions: $puzzle= "upload/$one".$_FILES['ufile']['name'][0]; $pdf= "upload/$two".$_FILES['ufile']['name'][1]; $png= "upload/$three".$_FILES['ufile']['name'][2]; //copy file to where you want to store file move_uploaded_file ($_FILES['ufile']['tmp_name'][0], $puzzle); move_uploaded_file($_FILES['ufile']['tmp_name'][1], $pdf); move_uploaded_file($_FILES['ufile']['tmp_name'][2], $png); //check file extensions $ext_puz = $puzzle[count($puzzle) - 1]; $ext_pdf = $pdf[count($pdf) - 1]; $ext_png = $png[count($png) - 1]; // ** Check for Required Fields with IF statements ** if (empty($title)){ $error = "** You forgot to enter a title **"; $flag=1; } if (empty($type)){ $error = "** Error: You forgot to enter the type of puzzle! **"; $flag=1; } if (empty($about)){ $error = "** Error: You forgot to enter any about info! **"; $flag=1; } if (empty($_FILES['ufile']['tmp_name'][0]) || (strtolower($ext_puz) != "jpz")) { $error = "** Error: You forgot to upload a puzzle file (jpz)! **"; $flag=1; } if (empty($_FILES['ufile']['tmp_name'][1]) || (strtolower($ext_pdf) != "pdf")) { $error = "** Error: You forgot to upload a pdf! **"; $flag=1; } if (empty($_FILES['ufile']['tmp_name'][2]) || (strtolower($ext_png) != "png")) { $error = "** Error: You forgot to upload a png solution file! **"; $flag=1; } I'm a bit stumped!
  19. Hi, I've written a script which uploads files. Now I have an upload file and I want to check that something has been uploaded AND it's a jpg: //check file extensions $ext = $exts[count($exts) - 1]; } if (empty($_FILES['ufile']['tmp_name'][0])) || (strtolower($ext) != "jpg") { $error = "** Error: You forgot to upload a jpg! **"; The first condition to check there is a file there works, but there is a problem with the OR or the condition after can anyone help? It states Parse error: syntax error, unexpected T_BOOLEAN_OR Thanks
  20. Hi All, Quick question, say I have a pic like this: Is there anyway using something, or some function in php that I can use to turn it round the right way before uploading? Thanks Chris
  21. Hi Guys, On my site I want to output all records in my database with two conditions Where the date (timestamp) is not greater than now but within the next 7 days? Can anyone help? I've got a feeling I need to use interval, but not sure? Thanks Chris
×
×
  • 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.