Suppress Column Names from MySQL Select

QuestionsSuppress Column Names from MySQL Select
Tony Wolsey asked 6 years ago

Hello

Is there an easy way to Suppress Column Names from what is returned by the MySQL Select Statement or in general within PHP?  I am trying to do some simple math with PHP and the column name, from the mysql select statement always prefixes the value.

I know there is a command line option of mysql -N that will do it but I am not sure if I can use this within PHP.

 

thanks

Tony

3 Answers
Abu Ghufran Staff answered 6 years ago

Hi,

I am unable to understand your question completely. In PHP, we always get the fetched data as array and it’s up to us what to display from that array.

If you want to hide column names when displaying data in grid, you can use following css and place it with html code to hide columns:

<style>
.ui-jqgrid-htable { display: none; }
</style>

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Tony Wolsey answered 6 years ago

Hello Abu

When I perform simple calcs in the mysql select statement and assign them to a variable, the results from the query seem to include the value of the field and the column name from the MYSQL DB.  Is there a way that I can exclude the column name from the MYSQL field and just return the field value only?  Referring to the below, I want to retrieve only the calculated field only values from Sum(quantity * automation). Then I can create the equation $autop = $auto/$finaltotal but this is not working.

$auto = $g->execute_query(“SELECT Format(Sum(quantity * automation),0) as ” FROM tblestimate where projectnumberest = ‘$groupselectednew'”);

$autop = $g->execute_query(“SELECT Format((Sum(quantity * automation)/$finaltotal) * 100,1) as ” FROM tblestimate where projectnumberest = ‘$groupselectednew'”);

thanks

Tony

Abu Ghufran Staff answered 6 years ago

You can try following. see bold.

$auto = $g->execute_query(“SELECT Format(Sum(quantity * automation),0) as tmp FROM tblestimate where projectnumberest = ‘$groupselectednew’”);

$finaltotal = $auto[0][“tmp”];

$autop = $g->execute_query(“SELECT Format((Sum(quantity * automation)/$finaltotal) * 100,1) as ” FROM tblestimate where projectnumberest = ‘$groupselectednew’”);

If you send complete code, i can review further. This is with my limited understanding.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

8 + 8 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?