How to Use SQL Macros Instead Of mysql_field_name in scriptcase 8.1 version?

I want to display field names using SQL Macros / sc macros

I want to display field names using SQL Macros, but I want to display Table field names eith the help of Sc Macros.

Actually I find Sc Macros i.e sc_select_field ({Field}) sc_select_order (“Field”), but these are not usefull to me.

please suggest me of this kind.

I use this code.

First set this at connection:

$this->Db->SetFetchMode(ADODB_FETCH_ASSOC);

then execute your query as usual

sc_select(ds, " select field1, field2 from table ");
if ({ds} === false)
{
echo "Database error. Message = ". {ds_erro};
}
else
{

while (! $ds->EOF )
{

       echo $ds->fields[ "field1"] . "</br>";
       echo $ds->fields[ "field2"] . "</br>";
						 
   $ds->MoveNext();
}
$ds->Close();

}

list of fields are in $ds->fields associative array.

Also you ca use FetchFiled to get the type of field.

Ciao ciao

Actually I want to display All Field names(Only Field Name not records form table)

like

<?php
mysql_connect(“localhost”,“root”,"");
mysql_select_db(“test”);
$sql=mysql_query(“select * from album”);//id,artist,title are field names in album table
$fc=mysql_num_fields($sql);
for($i=0;$i<$fc;$i++)
{
$fields=mysql_field_name($sql,$i);
echo “$fields<br>”;
}
/*
out put
id
artist
title
*/
?>

here My output should be like this


| Id | artist | title |

not entire table (fields not values)

[QUOTE=justdoit;39888]

here My output should be like this


| Id | artist | title |

not entire table (fields not values)[/QUOTE]

as I wrote

list of fields are in $ds->fields associative array.

execute the query and check the $ds->fields array, you’ll get the list of fields.

Here

I want to Display Only Fields/Field names(not entire table with Values).

Only Fields
Like


| Id | artist | title |

Can Any one Give me Example with Output .

and for the last time… do only these 3 steps

  1. $this->Db->SetFetchMode(ADODB_FETCH_ASSOC);

sc_select(ds, " select field1, field2 from table ");
if ({ds} === false)
{
echo "Database error. Message = ". {ds_erro};
}

  1. print_r ( $ds->fields );

I am getting Out Put like this

Array ( [Id] => 1 [0] => 1 [artist] => abc [1] => abc [title] => 1 [0] => 1 )

But I want Result Like Id,artist,title

Here I am getting
id=>1
artist=>abc
title=>one

I want to display all field names with select *

Display Only field headings not all values…

Excuse me, but please stop yelling around and start reading!

This is probably close to what you want. You can omit the ORDER BY clause if you don’t need/want it.


$sql = "SELECT GROUP_CONCAT( COLUMN_NAME ORDER BY column_name SEPARATOR ' | ')
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_SCHEMA = 'your_database' AND TABLE_NAME = 'your_table'";
sc_lookup(rs,$sql);
echo {rs[0][0]};

:slight_smile:

jsb

Good Morning jsbinca can you show me the Output of that.

Good Morning
I want to display only Field names

from a table


| Id | artist | title |

|1 | mp3 | one |
|2 | mp4 | two |

So here with the help of Macros or function I want to display

Id , artist , title (that is field names of a table)

In previous I used with mysql_field_name();

So I want a Sc Macros or function which is equals to mysql_field_name().

Thank you
Justdoit(MLN).