Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    243
    Thanks
    23
    Thanked 10 Times in 10 Posts

    select columns from table NOT = 'name'

    How do I select columns from table NOT = 'name'
    EXAMPLE:

    Code:
    $query = "SHOW COLUMNS FROM '$_POST[TableName]' WHERE column_name != 'SerialNo'";
    or ....
    Code:
    $query = "SHOW COLUMNS FROM '$_POST[TableName]' WHERE column_name NOT LIKE '%SerialNo%'";
    Which one is it?
    a> != 'SerialNo'"
    b> NOT LIKE '%SerialNo%'
    c> NOT = 'SerialNo'

    None of these operators work according to the MySql manual
    Last edited by DataTalk; 06-23-2013 at 09:05 AM.

  • #2
    Regular Coder
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    243
    Thanks
    23
    Thanked 10 Times in 10 Posts
    I managed to resolve this on my own in this example:

    Code:
    $q2 = mysql_query("SELECT * FROM $tablename");
    $fields  = array();
      while ($q2_data = mysql_fetch_field ($q2)) {
        if ($q2_data->name != 'weight' && $q2_data->name != 'id'){
          $fields[] = "$q2_data->name"; 
    }}
    This will reports the selected fields and i desire. Does anyone disagree with this resolution?

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    243
    Thanks
    23
    Thanked 10 Times in 10 Posts

    Using database stored style-sheets

    this page was not necessary

  • #4
    Regular Coder
    Join Date
    Nov 2010
    Location
    Oregon
    Posts
    243
    Thanks
    23
    Thanked 10 Times in 10 Posts
    I have created style sheets that are stored in the database which creates forms and reports the fly using php, html, and css.

    Will this be a problem in the future with a large number of users? or should all the data-entry forms and reports be static userforms.php

  • #5
    New Coder
    Join Date
    Jan 2009
    Posts
    58
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Well as with any application the more you scale the slower it becomes,
    but as long as your code is secure I don't see anything particularly bad about doing this, especially if your forms are being dynamically created.

    I would however warn against storing executable php code in a database, because it means you will need to use eval() at some point, which can be a bit risky...


    Also im kinda sad to post this, because at the moment you were having a great time conversing with yourself for the last hour or so...

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    To select column names, you'll need to poll the information_schema table. Try this:
    Code:
    SELECT COLUMN_NAME
    FROM INFORMATION_SCHEMA.COLUMNS
    WHERE TABLE_SCHEMA = 'dbname'
    AND TABLE_NAME = 'tablename'
    AND COLUMN_NAME NOT IN ('id', 'weight')
    Where dbname is your database name and tablename is your, well, table name

    As for db stored data, sometimes that's a bit of a gamble. The client should be caching anything it gets such as a stylesheet, so long as it has an older modification date and isn't accepting dynamic data. Filesystem access is always faster than dbms access, but you do have advantages from using a dbms over a filesystem. You're simply storing a template within the dbms. An example I can think of off the top of my head is the vBulletin software on the forums here which (at least to the last version I owned which was 3.0) does use dbms templates which are really easy to work with for both version controls and using custom templates for different themes.
    Can certainly be done on a filesystem. There it would be faster to access and not count against any query meter (dbms' can be locked down to a maximum number of requests per hour for example). I wouldn't suggest executable code within the dbms either; eval is a very dangerous function depending on use. The filesystem approach is much better to process the PHP through standard PHP usage, but it does take use of either injecting variables within it, simply populating and specific locations within a script, or using a custom replacement handling (simple {BODY} -> "This is a body" for example).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •