Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. try include ('simple_html_dom.php'); $doc = file_get_html("http://www.estatesgazette.com/propertylink/advert/4th_floor_pear_mill_industrial_estate_stockport_cheshire-stockport_cheshire-3383230.htm"); $title = $doc->find('title',0); echo $title->plaintext; I remember the Pear Mill, and the Welkin Mill across the road, when they were mills
  2. I've never had that problem. The above code I posted gave 4 days (OS = Windows 7, PHP version = 5.3.10)
  3. Can you post your table structures, some sample data and what you expect to be returned from that data?
  4. You have some redundant code - what does this give? $date1 = new DateTime("2013-12-07"); $date2 = new DateTime(); echo "<br>"; $Gap = date_diff($date1, $date2); echo $Gap->format("%a") . ' days'; edit: BTW it isn't a MySQL problem - moving
  5. That query should find all matching records
  6. Two problems with this query 1. "company" should be "$company" 2. the query never gets called. You don't need the two queries, a single joined query will do the job more efficiently $sql = "SELECT cd.order_nr, cd.amount_paid FROM complaint c INNER JOIN complaint_details cd USING (complaint_nr) WHERE c.d_name = '$company' ";
  7. It already finds multiple areas in the $gaps array. At the moment it sorts them and just uses the largest in $gap[0]
  8. Where I had "company.php" then that should be the name of the page you want to link to. On that page use something like $company = isset($_GET['company']) ? $_GET['company'] : ''; if ($company) { // query your database table for the company record and display // using "... WHERE d_name = '$company' " } else { // error - no company selected, return to company list page }
  9. You posted the identical question 22 minutes before posting this one
  10. Do not double post.
  11. output the d_name as a link, passing the company in the url querystring echo "<td><a href=\"company.php?company={$debtor['d_name']}\">{$debtor['d_name']}</a></td>";
  12. $db would be the mysqli connection. Change it to $con as that is the variable you are using.
  13. Wouldn't it be more sensible to validate before sanitizing as the content could be affected by mysql_real_escape_string()?
  14. An array would be the preferred method but "variable variables" (using $$) will also work $Text1="Hi, how are you"; $Text2="Hey there stranger"; $Text3="Its about time!"; $random_number = rand(1,3); $WelcomeText = "Text$random_number"; echo $$WelcomeText;
  15. I thought I had answered that one. MySQL gave us DATE, DATETIME and TIMESTAMP type specifically for storing dates and times and also dozens of datetime functions to make life easier when dealing with them. If you use other types then you will always have to do a conversion before you can use these functions. In addition, these date types have the advantage of being "human-readable". If you ever have to browse your db tables when you have problems (and you will) then a value like "1386591094" is meaningless to mere mortals whereas "2013-12-09 12:11:34" is instantly recognizable.
  16. Have you considered the "visual" approach to seat booking?
  17. There are five "forecast" elements. You are overwriting each one so you end up with just the last one. $countryId=16756; $xml = simplexml_load_file("http://weather.yahooapis.com/forecastrss?w=$countryId&u=c"); $xml->registerXPathNamespace("yweather", current($xml->getNamespaces())); echo $xml->channel->title . '<br>'; foreach ($xml->xpath('//yweather:forecast') as $item) { echo "<i>{$item['day']} {$item['date']}</i> — Low:{$item['low']}° High:{$item['high']}°, {$item['text']}<br>"; } /*** OUTPUT *********************************** Yahoo! Weather - Congleton, GB Sat 7 Dec 2013 — Low:6° High:7°, Partly Cloudy Sun 8 Dec 2013 — Low:8° High:11°, Partly Cloudy Mon 9 Dec 2013 — Low:5° High:9°, Partly Cloudy Tue 10 Dec 2013 — Low:4° High:8°, Partly Cloudy Wed 11 Dec 2013 — Low:3° High:7°, Mostly Sunny ***********************************************/
  18. What should $countryId be in
  19. You are getting day as Wednesday and Wednesday's date. What is your code to get tomorrows date?
  20. I'd also recommend a better structure for your XML <root> <person seq="1"> <first> john </first> <last> doe </last> </person> etc </root>
  21. or you could structure like this index.php <form action="insert.php" method="post"> <?php for ($i=1; $i<=5; $i++) { echo "Name: <input type='text' name='name[$i]' size='12' /> Email: <input type='text' name='email[$i]' size='12' /> Phone: <input type='text' name='phone[$i]' size='12' /> <br><br>\n"; } ?> <input type="submit" name="btnSubmit" value="Submit"> </form> insert.php if (isset($_POST['name'])) { $data = array(); // loop through the arrays of fileds foreach ($_POST['name'] as $k => $name) { $email = $_POST['email'][$k]; $phone = $_POST['phone'][$k]; // if data OK process if ($name && $email) { // very simple validation! Phone is optional $data[] = sprintf("('%s', '%s', '%s')", $db->real_escape_string($name), $db->real_escape_string($email), $db->real_escape_string($phone) ); } } // insert all the records with a single query $sql = "INSERT INTO contact (name, email, phone) VALUES \n" . join(",\n", $data); $db->query($sql); } // back to input form header("Location: index.php");
  22. Define your table column to have default value. If the image value is null, exclude that column from the insert query. If no value is inserted in the column then the default will be used. edit: BTW that table needs normalizing.
  23. If their birthday has already passed by this year then the next birthday is next year otherwise it is this year, so $sql = "SELECT FROM_UNIXTIME(staffDOB) as dob FROM staff WHERE CASE WHEN DATE_FORMAT(FROM_UNIXTIME(staffDOB),'%m%d') < DATE_FORMAT(CURDATE(),'%m%d') THEN CONCAT(YEAR(CURDATE())+1, DATE_FORMAT(FROM_UNIXTIME(staffDOB),'-%m-%d')) ELSE CONCAT(YEAR(CURDATE()), DATE_FORMAT(FROM_UNIXTIME(staffDOB),'-%m-%d')) END BETWEEN CURDATE() AND CURDATE()+INTERVAL 14 DAY"; Fife, please use DATE type fields and not unix timestamps - it saves all that conversion when processing dates
  24. ... unless CURDATE() is in the last two weeks of December
  25. try this method instead SELECT a.name, 1+COUNT(b.name) as rank FROM highscores a LEFT JOIN highscores b ON a.type = b.type AND b.Gf-b.Ga > a.Gf-a.Ga WHERE a.type = 'VbStory' GROUP BY a.name; +---------+------+ | name | rank | +---------+------+ | Gustavo | 1 | | Test | 2 | +---------+------+
×
×
  • 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.