Jump to content

mcfc4heatons

Members
  • Posts

    11
  • Joined

  • Last visited

mcfc4heatons's Achievements

Member

Member (2/5)

0

Reputation

  1. I've seen this in some PHP source code: number_format((float)$thenumber, 2, '.', ''); What is the difference between that and this?: number_format($thenumber, 2, '.', ''); thanks...
  2. I have the same query filtered by two different conditions and want to check if it returns results, in the example below I write two queries and use the RecordCount function, but is there a more efficient way to do this with just one query ? $query1 = "SELECT col1, col2 FROM table WHERE catid = 1"; $result1 = $db->execute($query1); $totalRows_result1 = $result1->RecordCount(); $query2 = "SELECT col1, col2 FROM table WHERE catid = 2"; $result2 = $db->execute($query2); $totalRows_result2 = $result2->RecordCount(); if ($totalRows_result1 < 1) { echo 'sorry, category 1 has no items'; } if ($totalRows_result2 < 1) { echo 'sorry, category 2 has no items'; }
  3. I'm working on a PHP ADODB Project and want to reuse a query result and loop through results again, at the moment I am using the following approach, but assume this is inefficient and there must be a better approach?: $query = "SELECT colname FROM table"; $result1 = $db->SelectLimit($query,10,-1); $result2 = $db->SelectLimit($query,10,-1); // 1ST RUN while (!$result1->EOF) { echo $result1->Fields('colname').'<br>'; $result1->MoveNext(); } // 2ND RUN while (!$result2->EOF) { echo $result2->Fields('colname').'<br>'; $result2->MoveNext(); }
  4. I have a project on localhost with some dynamic data from MYSQL being echoed to page and it UTF-8 content including symbols like '£' are outputted correctly. When I upload to remote, I get '?' placeholders instead of some symbols, evidently not outputting as UTF-8. DB on remote is UTF-8, PHP file is UTF-8 format, UTF-8 is the default PHP encoding on remote. I just can't understand why not outputting UTF-8 correctly on remote?
  5. hi, How does one one write multiple conditional WHERE clauses where any values that are null are not part of the query Like this but where each one is only part of the where clause if the value is not null SELECT * FROM table WHERE col1 = ? AND col2 = ? AND col3 = ? AND col4 = ?
  6. OK, I worked it out: INSERT Into table2 (related_id) SELECT id FROM table1 WHERE id NOT IN (SELECT related_id FROM table2)
  7. this returns all the the records from table1 that are not in table2, just not sure how to combine an insert of the missing records into table2 ? SELECT id FROM table1 WHERE id NOT IN (SELECT related_id FROM table2)
  8. Hello, What's the correct way to compare two tables and update table 2 with any missing IDs? Scenario: Table 1 with primary key 'id' Table 2 with foreign key column 'related_id' linked to Table 1 'id' column Compare the two tables and insert any missing IDs into table 2 foreign_key 'related_id' column
×
×
  • 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.