Jump to content

Barand

Moderators
  • Posts

    24,612
  • Joined

  • Last visited

  • Days Won

    834

Everything posted by Barand

  1. ... or add a UNIQUE key to the field to make it impossible to add the same one twice
  2. You don't even need a loop. You can check the whole array with a single statement if ($input != str_replace($myArray,'', $input) ) { echo "Contains an existing value"; }
  3. You have only the database name
  4. Using an aggregation function (SUM(), COUNT() etc) without specifying a GROUP BY column(s) will return a single row containing the aggregate for the whole selection. Values for the other non-aggregated selected columns are indeterminate (although usually from the first record in the set.
  5. looks like data is array to me $obj = (object)[ 'name' => 'my name', 'data' => [2,4,6]]; print_r($obj); /* results ******************** stdClass Object ( [name] => my name [data] => Array ( [0] => 2 [1] => 4 [2] => 6 ) ) */
  6. $obj = (object)[ 'name' => 'my name', 'data' => [2,4,6]];
  7. Translating the above to sqlsrv dialect WHERE DATEPART(yyyy, datefield) = targetyear AND DATEPART(mm, datefield) = targetmonth
  8. Easiest way is to read the results into an array and then use array_chunk() with a chunk size of 5. Output each chunk as a row.
  9. perhaps +-------------+ | chart | +-------------+ +-------------+ | +---------------+ | series | | | category | +-------------+ | +---------------+ | | | | /|\ | | +-------------+ | +-------------<| value |>--------------+ +-------------+
  10. So if your categories are the continents then you could have a chart showing population growth, say, but you could not then have another chart for those continents showing economic growth.
  11. According to that model, a chart can have many categories but a category can belong to only one chart.
  12. The idea is to "USE databasename" to set the correct database name as default
  13. I can think of only three ways Only ever have a single database on your server Execute the statement "USE databasename" before every query. In INSERT, UPDATE and DELETE queries always prefix the table names with dbname (ie dbname.tablename). No damage is done with SELECT queries I suppose a fourth way is be careful what you are doing
  14. Use "SELECT DISTINCT ... " You seem to have design flaws in the database. If the table contains the id and name then they should be unique. If, on the other hand, it's a table at the "many" end of a one-to-many relationship then the name shouldn't be in the table, just the id.
  15. see https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_the_Ultimate_Question_of_Life.2C_the_Universe.2C_and_Everything_.2842.29
  16. You might want to consider altering the logic of the program so that if there are no results to display then you do not even attempt to paginate nothing.
  17. Something I've already told them in another post (http://forums.phpfreaks.com/topic/301723-error-saving-data-in-mysql-table/). Why do we bother?
  18. HTML colours have three colour components, namely red, green and blue. Each of these has a value ranging from 0 to 255. These are expressed as hexadecimal values 00 to FF. #FF0000 = red #00FF00 = green #0000FF = blue equal quantities of each component gives a grey color, for example #888888 gives a mid-grey. In the function, the variables $r, $g and $b are the red, green and blue values. Those look fairly meaningful to me, better than $peter, $paul and $mary.
  19. Having got the data into a CSV file you can load it into a MySql table using LOAD DATA INFILE statement
  20. Not throwing an error does not mean it works. It removes the characters from the text fields also It still leaves commas in the currency field
  21. @requinix - It was tricky getting the timing just right
  22. try $sql = "SELECT co.id , co.name , car.id , car.model FROM companytest co INNER JOIN cartest car ON co.id = car.make ORDER BY co.id, car.id"; $res = $db->query($sql); $cars = []; $prev = ''; while (list($coid, $coname, $cid, $model) = $res->fetch_row()) { if (!isset($cars[$coid])) { $cars[$coid] = ['id' => $coid, 'name' => $coname, 'cars' =>[] ]; } $cars[$coid]['cars'][] = ['id' => $cid, 'model' => $model]; } the data mysql> select * from companytest; +------+----------------+ | id | name | +------+----------------+ | 1 | Ford | | 3 | General Motors | | 5 | Chrysler | +------+----------------+ 3 rows in set (0.00 sec) mysql> select * from cartest; +------+------+------------+ | id | make | model | +------+------+------------+ | 1 | 1 | Mustang | | 2 | 1 | Fusion | | 3 | 3 | Corvette | | 4 | 3 | Escalade | | 5 | 5 | Charger | | 6 | 5 | Challenger | +------+------+------------+ 6 rows in set (0.00 sec)
  23. Do you have error reporting turned on? Have you checked the values of mysqli_error? I cannot do it for you.
  24. Similarly, the code you just posted, the input to simplexml_load_string() is $result->GetDailyListingSummaryResult->any That should be the XML.
  25. First step to debugging is to have error_reporting switched on and also check for mysqli_error values after attempting queries. Where is $resultat defined? If it isn't it should be throwing an "undefined variable" error.
×
×
  • 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.