-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
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
-
I've never had that problem. The above code I posted gave 4 days (OS = Windows 7, PHP version = 5.3.10)
- 6 replies
-
- ajoo
- difference between 2dates
-
(and 1 more)
Tagged with:
-
Can you post your table structures, some sample data and what you expect to be returned from that data?
-
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
- 6 replies
-
- ajoo
- difference between 2dates
-
(and 1 more)
Tagged with:
-
That query should find all matching records
-
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' ";
-
It already finds multiple areas in the $gaps array. At the moment it sorts them and just uses the largest in $gap[0]
-
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 }
-
You posted the identical question 22 minutes before posting this one
-
Do not double post.
-
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>";
-
$db would be the mysqli connection. Change it to $con as that is the variable you are using.
-
Wouldn't it be more sensible to validate before sanitizing as the content could be affected by mysql_real_escape_string()?
- 14 replies
-
- sql
- sqlinjection
-
(and 3 more)
Tagged with:
-
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;
-
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.
-
-
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 ***********************************************/
-
What should $countryId be in
-
You are getting day as Wednesday and Wednesday's date. What is your code to get tomorrows date?
-
How do I convert a csv file to xml in php?
Barand replied to saywhatyousee's topic in PHP Coding Help
I'd also recommend a better structure for your XML <root> <person seq="1"> <first> john </first> <last> doe </last> </person> etc </root> -
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");
-
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.
-
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
-
... unless CURDATE() is in the last two weeks of December