If you need to extract the information from a PDF table sometimes when you copy and paste it into a text editor the formatting is incorrect making the information useless. In cases like this, you can use pdfedit to extract the text in the correct formatting and then do what you need with it. To [...]
Archive: table
Posts Tagged ‘table’
If you need to update a large number of rows on a single table then your first reaction may be to write a loop that updates one row at a time. Of course if the table is large then this can result in a very large number of SQL queries. Taking a bit of inspiration [...]
If your osCommerce checkout starts behaving badly and bits of info seem to go missing eg billing address then you should definitely try this fix before you tear your hair out completely. Most osCommerce installs store session information to a MySQL table called (suprisingly) sessions. Sometimes (I have only seen this twice on umpteen osCommerce [...]
This little PHP function will allow you to import a csv or tab etc delimited text file into a database table. Handy if you need it PLAIN TEXT PHP: function build_table_from_file($tablename, $filepath, $delim="\t") { db_query("DROP TABLE IF EXISTS $tablename"); $fp=fopen($filepath, 'r'); $headers=false; while($r=(($delim=='csv')?fgetcsv($fp):fgets($fp))) { [...]
If you are feeling lazy, or would like to build in some future proofness into your system, you can use the MySQL Desc query to get table column information and then use this information to create dynamic SQL insertion strings. For example: PLAIN TEXT PHP: $cols_query = db_query("desc table"); while($cq = mysql_fetch_assoc($cols_query)){ $cols[]=$cq; [...]
Sometime you need a PHP script to check for the existence of a MySQL table. This function achieves that for you. PLAIN TEXT PHP: function db_table_exists($table){ $exists = false; $tables_query = db_query("SHOW TABLES FROM " . MYSQL_DB); while($t = mysql_fetch_assoc($tables_query)){ foreach($t as $k=>$v){ [...]