Jump to content

Barand

Moderators
  • Posts

    24,606
  • Joined

  • Last visited

  • Days Won

    831

Everything posted by Barand

  1. WHERE user_id = ? AND address_type = 1
  2. You have to put your output inside HTML table tags (table, tr, td). Have a look at html table structure and output your data to match that Example <table> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> </table>
  3. Your search field name is "search", not "name" $name=$_POST['search'];
  4. while($row = $stmt->fetch()) { $array[$address_type] = array($street_no, $street_name, $city); }
  5. Everything between the textarea tags is part of the value, including all the whitespace in your source. Use <textarea name="comments"><?php echo $comments; ?></textarea>
  6. You are testing that the title, quantity and price arrays are not empty, but you could still have blank values inside those arrays
  7. try $xml = simplexml_load_string($str) ; $content = (array)$xml->content; unset($content['@attributes']); foreach ($content as $k => $item) { echo "$k = '$item'<br>"; }
  8. This worked for me Data (zodiac.txt) 1884 Pig 2004 Dog 2005 Rat CREATE TABLE zodiacyears ( year smallint primary key, name varchar(10) ); load data infile 'C:/inetpub/wwwroot/. . ./zodiac.txt' into table zodiacyears fields terminated by ' '; mysql> select * from zodiacyears; +------+------+ | year | name | +------+------+ | 1884 | Pig | | 2004 | Dog | | 2005 | Rat | +------+------+
  9. Make sure your "path_to_file" is the full system path to the file on your server
  10. the operator ".=" appends to the variable. $current is only set to null by default if you do not pass a third parameter when you call the function. The option with the value that matches $current is set as selected. If none are "selected" the first option is selected by default You would echo the result returned by the function wherever you want that menu displayed It returns an array that you pass to the first function to build a menu Variables are local to functions. You can use the same variable name in as many functions as you like. They are different variables and only exist while the function is executing (unless static)
  11. You are adding each date as a separate item. You need to add the date pairs as one item then join the items using "<br>" if ($sd){ $item = date_format(($sd), 'm/d/y'); //m/d/y } if ($ed){ $item .= '-' . date_format(($ed), 'm/d/y'); //m/d/y } $data[$cid]['events'][$m][] = $item; }
  12. I'd add an empty result array to that function's arguments, then call it recursively. function someFunc(&$res, array $keys, $data) { if (!empty($keys)) { $k = array_shift($keys); someFunc($res[$k], $keys, $data); } else $res = $data; } // call the function $res = []; someFunc($res, array('key1','key2', 'key3'), 'data'); echo $res['key1']['key2']['key3']; //--> data
  13. Then you're doing it incorrectly. Post current code.
  14. try applying this to your "td" css white-space: nowrap;
  15. $recipient is a string containing a single email. You need to implode the array "$exploded_new_recipients"
  16. INSERT statements don't have WHERE clauses. If you don't want to allow duplicate titles, add a UNIQUE constraint to the title column
  17. We have told you how you should be tackling the problem and you have ignored those suggestions and decided to take this approach. You can go on forever trying to adjust the query to work for each particular situation as it arises. The correct approach is a proper data structure and queries that work for all eventualities.
  18. PHP concatenation operator is "." and not "+"
  19. Sorry, arithmetic on a NULL value produces null result SELECT i.`quantidade` - IFNULL(SUM(r.`quant`),0) AS total FROM `item` AS i LEFT JOIN `requisicoes` AS r ON (r.`id_item` = i.`id_itens`) AND r.`startDate` = "2015-11-22 11:30" AND r.`endDate` = "2015-11-23 11:20 WHERE i.`id_itens` = 8
  20. The simple answer is "No". If you want to select all, don't specify the IN() condition
  21. One or two things wrong with that query. 1. Your calculation - If you had two loans, each of 10 books, then you would expect a result of 10 remaining. Yours would give (30-10) + (30-10) = 40. You need i.`quantidade` - SUM(r.`quant`) AS total 2. Your join - INNER JOIN retrieves records only when there is a matching record in both tables. If one table has no record then no results. You need FROM `item` AS i LEFT JOIN `requisicoes` AS r ON (r.`id_item` = i.`id_itens`) so that you select the item record even if there are no req records. Having changed to a LEFT join you need to change the WHERE clause so it doesn't contain conditions on the req data. Those need to go in the join condition. So the query now becomes SELECT i.`quantidade` - SUM(r.`quant`) AS total FROM `item` AS i LEFT JOIN `requisicoes` AS r ON (r.`id_item` = i.`id_itens`) AND r.`startDate` = "2015-11-22 11:30" AND r.`endDate` = "2015-11-23 11:20 WHERE i.`id_itens` = 8
  22. you could use something like this SELECT a.user , group_concat(b.user) as guests , count(b.guestof) as total FROM userlist a LEFT JOIN userlist b ON b.guestof = a.user GROUP BY a.user ; +-------+-----------+-------+ | user | guests | total | +-------+-----------+-------+ | Bill | Jason | 1 | | Frank | NULL | 0 | | Gwen | NULL | 0 | | Jack | Gwen,Matt | 2 | | Jason | Jill,Jack | 2 | | Jill | Frank,Stu | 2 | | Matt | NULL | 0 | | Stu | NULL | 0 | +-------+-----------+-------+
  23. In addition, your SQL query syntax is wrong. String values need to be in single quotes INSERT INTO student_register_test10 (name, address, topic1) values ('$name', '$address', '$topic1' )
  24. How does that work? There doesn't appear to be anything to say books have been returned, or not
×
×
  • 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.