Render table contents with varying number of fields

Codes here !

Moderators: egami, macek, gesf

Post Reply
decroded
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Apr 13, 2018 11:28 pm

Fri Apr 13, 2018 11:54 pm

Hi Im new here.
I used to dabble 15 years ago but lots has changed.
Im not needing code but rather the general process and recommended functions as i seem to be finding way more obselete info than current.
My purposes right now are merely experimental and for learning so Im not concerned with performance on large data or security right now.

Ive setup new LAMP stack (all latest versions) and my user can read/write MariaDB (GRANT ALL) via mysqli so all good.

Now what i want to do is take a raw dump of table contents into an object and echo it into a grid based on the number of fields in the table.
I have this working fine right now but I want to access things like the field names and Im not very confident with manipulating data objects.

I tried below code to access information schema to count columns and its returning nothing with no errors so not sure what’s up with that.

Code: Select all

SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = 'targets’
  AND table_name = 'sales’
While I want to be able to do it this way, i also want to know the alternatives as i know its not best practice to rely on schema.


Thanks for any help!

decroded
New php-forum User
New php-forum User
Posts: 2
Joined: Fri Apr 13, 2018 11:28 pm

Sat Apr 14, 2018 10:39 pm

This is basically solved now not sure how to tag it complete.

I did a bunch of experiments with objects vs associative arrays and various functions and I’m starting to get it.
Ready to move onto move on to more advanced data manipulation and flexible pipelines that don’t contain any hard coding so still appreciate any cool tips.
Next logical step seems to be to build some generic classes with methods for common use like fetching and manipulating.

Post Reply