Jump to content

garynobles

New Members
  • Content count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About garynobles

  • Rank
    Newbie
  1. garynobles

    displaying a table and hear automatically

    So I guess I need an if statement, how close am I with this? if $row!=0 { }else{ echo"empty table";} location in the code $sql = "SELECT whatever FROM wherever"; $res = $db->query($sql); //here should be the start of an if statement: if $row!=0 {}else{echo"empty table";} while ($row = $res->fetch(PDO::FETCH_ASSOC)); echo "<table border='1'><tr><th>"; echo join('</th><th>', array_keys($row)) . "</th></tr>\n"; do { echo "<tr><td>" . join('</td><td>', $row) . "</td></tr>\n"; } while ($res->fetch(PDO::FETCH_ASSOC)); echo "</table>\n";
  2. garynobles

    displaying a table and hear automatically

    Of course! I was staring at that line but I couldn't see it. One additional thing, I feel like I'm being cheeky... On one of the tables I get: Warning: join(): Invalid arguments passed in /var/www/rhp.archaeolabs.nl/tables.php on line 42 Warning: array_keys() expects parameter 1 to be array, boolean given in /var/www/rhp.archaeolabs.nl/tables.php on line 40 Warning: join(): Invalid arguments passed in /var/www/rhp.archaeolabs.nl/tables.php on line 40 line 40 = echo join('</th><th>', array_keys($row)) . "</th></tr>\n"; line 42 = echo "<tr><td>" . join('</td><td>', $row) . "</td></tr>\n"; so somewhere I have a boolean - I have some data stored as double format, would that be it, is there a way to code around this or should I change the 'double' to something else like decimal?
  3. I'm using Talend for data migration, it allows for Regex, I'm, new to Regex, but I'm learning, I have data like so: QA01_Q1254 RT04_123ht12 ... I want to get Q1254 123ht12 ... and then how would you do the opposite QA01 RT04 ... I've been trying various syntax deviations, but not getting the right data out. Any help much appreciated.
  4. garynobles

    displaying a table and hear automatically

    In response to Barand, great! Expect it repeats the first row repeatedly for the number of rows, rather than displaying all the data e.g. ID_SITO ID_UNITA ID_UR_A DAT1 DAT2 RESPONSABILE ID S1 S1-1 -350 220 Sforza 4 S1 S1-1 -350 220 Sforza 4 S1 S1-1 -350 220 Sforza 4 ... it continues for 500+ rows As for requinix, I understand your concerns, the users are not creating tables, I want to display the tables via php/html. So they cannot make new tables, I'm using hyperlinks with GET rather than POST, these are coming from a specific schema, so it can't be manipulated to access system tables.
  5. I've been coding in php for a while but I always define the tables (and headers) in hard code. I'm wanting to automate the creation of a table (table selected via a GET request - select * from $_GET["table"] - not important for now). I've been reading that you need to first count the columns and get them as row 0 then fetch the data using an auto increment for the rows i++. I learn from examples, and I just can't find anything I can manipulate, this surely is a common task? I'm using PDO (postgresql) so to get the code under way: $sql = "SELECT * FROM rsp.bibliografia"; //will be the result of a get request $result = $conn->prepare($sql); $result->execute(); Any help is greatly appreciated.
×

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.