visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: ODBC


By: gvector1 U.S.A.  Date: 12/05/2003 00:00:00  English  Points: 50 Status: Answered
Quality : Excellent
Hello everyone,

Got a question of course. In C++/ODBC, there is are a few functions that will return information about a result set(ex. SQLDescribeCol, and SQLColAttribute). The problem is that most of the values, namely the data type is returned as a Numeric Pointer. It is returned as a number. Namely for the data type, how do I know which data type each number represents? Is there a chart somewhere that tells that? I need to know so I can make the necessary conversion to C data types. I know I can use SQL_C_CHAR as a substitute for most of the data types, but that is just a workaround. I want to do this correctly, and besides, it will give me more flexability. Any suggestions?????

Thanks a million,
Kendal


By: VGR Date: 12/05/2003 00:56:00 English  Type : Comment
only one : put the cursor over SQLColAttribute and press F1
By: VGR Date: 12/05/2003 00:57:00 English  Type : Answer
***or*** issue this query towards MySql :

DESCRIBE tablename;

and deduce the types of the columns by yourself by parsing the results, it's easy.
By: gvector1 Date: 12/05/2003 02:54:00 English  Type : Comment
I suppose if I can't find a standard for SQL to C data conversion, I will have to design an SQL database with every data type and then have a program go through output the data type value of every column in order to figure out the corresponding number to the data type. I just can't help but think that there is a standard out there for MYSQL. If it is checked out on the MSDN website here : <A HREF="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odch10pr_7.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odch10pr_7.asp</a>

It is described in the sample program that the unshown function contains a switch statement that returns the associated C data type for the SQL data type. I just cannot find anybody that knows the standard.
By: VGR Date: 12/05/2003 03:11:00 English  Type : Comment
yes, sure, but this is a C++/ODBC-related problem, right ? So the solution should ***also*** lie (huh huh huh) in the C++/ODBC documentation, shouldn't it ?

the "describe table" trick frees you from such oddities, and lets you detect yourself an :
-integer, char(40), text, float(4,2) etc
By: gvector1 Date: 12/05/2003 03:38:00 English  Type : Comment
I have searched the C++/ODBC documentation until my monitor hurts (ha ha) and cannot find anything that will clearly tell my about it. The documentation I have found everywhere(MSDN, MYSQL, etc) tells you what you already know and then drops it. Just like the sample on the MSDN website at the above link. Tells you there is a function there but that is it.
*********************
the "describe table" trick frees you from such oddities, and lets you detect yourself an :
-integer, char(40), text, float(4,2) etc
*********************
Question:
If the application gives the "describe table" command, I should be able to pull the Type value from the 2nd column?????

But even if I can do that, that gives me the data types for the whole table. The application does not know what fields are being requested at the time and therefore does not know what type of allocation to make or binding to do. That is why I was trying to use "SQLDescribeCol" or "SQLColAttribute".
By: gvector1 Date: 12/05/2003 03:40:00 English  Type : Comment
I think I realize what you are trying to say:

Use the describe table command in the application to associate the type with the field name. When the Select command is given, make a comparison with the "association table" made using the "describe" command and then allocate and bind based on that??????????????

Is that what you were trying to say?????????
By: VGR Date: 12/05/2003 03:51:00 English  Type : Comment
absolutely, but usually used the reverse way :
YOU (programmer) build the queries, right ? So YOU know which fields there are.

In stead of hardcoding the fields' names, you use $fieldNames[$i] for instance, and you've also memorized $fieldTypes[$i] that tells you the available length (for FORM display via MAXLENGTH=), for putting quotes around values or not (text/numeric) etc

If you're interested, I've a relatively interesting script to show you 8-)

in your case, as you asked for "being able to know the type of each column", well the answer is that if you take the columns in the same order as the lines of results of DESCRIBE tableame;, then you've got your info :D
By: VGR Date: 12/05/2003 04:45:00 English  Type : Comment
it's also a good solution
By: gvector1 Date: 12/05/2003 17:24:00 English  Type : Comment
The only thing is that I cannot take the columns in the order as the lines of results in the describe table result set. I am actually practicing with MYSQL to learn it so I can implement it in a system I am trying to design. I am designing an EMR(Electronic Medical Records) System for a medical clinic. Eventually the end users will be making queries from the application that is not know until runtime. Therefore the application will need to decifer the details of the SQL statement.

Also, I just recently found out how to do what I have been trying to do. I actually do not need to know what numeric pointer value corresponds to the SQL variable type. I can make a comparison like this:

if (ColType == (SQLINTEGER *)SQL_VARCHAR)
cout << "It worked, it is a VarChar!!!" << endl;
else
cout << "Try again!!!!" << endl;

Where "ColType" is a SQLINTEGER * that holds the result from the SQLColAttribute function call. This actually works. So simple, yet I could not figure it out until just recently. Always learning something new:)

You said you had a script to accomplish what you were talking about. Is it in C++????

By: VGR Date: 12/05/2003 17:41:00 English  Type : Comment
no

the user may build his query using an HTML FORM (for fields's values), for instance, whithout the script to actually "know" the names of the fields. It just knows it's index $i in the fieldsNames[] array, for type fieldType[$i] and length X

the query is then built dynamically by a single function that matches selections with the fieldsNames[] and related arrays.

think about it 5 minutes and you'll see.

For your enlightenment (may-be), I drop this for you :
There is unrelevant code in it, comments, perverted accentuated characters (thanks EE ;-) but you'll find what you search for IMHO


<?
// gestDB.php : gestion des bases de donnies (ie tables)
//
//VGR18032003 VERSION ginirique
//
//TODO : nil
//

session_start();
require 'session.inc.php'; // prevents passing below if not logged in

//begin
header("Refresh: 9999"); /* set browser refresh period ` 9999s (jamais, 2,77h) */
echo "<HTML><BODY BACKGROUND=\"\" BGCOLOR=\"000000\" VLINK=\"FF0000\" TEXT=\"FFFFFF\" LINK=\"8080FF\">";
echo "Bonjour $sess_pseudo.&nbsp;&nbsp;<a href=\"$SCRIPT_NAME?quitte=1\">Quitter</A>
";
if ($sess_pseudo=="visiteur") { LogAction($sess_pseudo,$REMOTE_ADDR,"se fait jeter de la gestDB.",2); echo "Cette page n'est pas accessible aux visiteurs, enregistrez-vous d'abord.(cf Aide)"; exit;}

if (isset($getTable)) {
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : acchde ` la table $table dans $dbName.",2);
}

if (isset($getDB)) {
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : acchde ` la base $datab.",2);
}

if (isset($quitte)) {
session_unregister("datab");
session_unregister("table");
session_unregister("globTableLue");
session_unregister("globChAcc");
session_unregister("globLimited");
session_unregister("globChLon");
session_unregister("globNbChamps");
session_unregister("globChNom");
session_unregister("globChTyp");
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : quitte.",2);
echo "Session de gestion des DBs tuie, utilisez le menu de gauche.";
echo "</BODY></HTML>";
exit;
}
if (isset($change)) {
session_unregister("table");
unset($table);
session_unregister("datab");
unset($datab);
session_unregister("globTableLue");
session_unregister("globLimited");
session_unregister("globChAcc");
session_unregister("globChLon");
session_unregister("globNbChamps");
session_unregister("globChNom");
session_unregister("globChTyp");
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : change de DB.",2);
}
if (isset($change2)) {
session_unregister("table");
unset($table);
session_unregister("globTableLue");
session_unregister("globLimited");
session_unregister("globChAcc");
session_unregister("globChLon");
session_unregister("globNbChamps");
session_unregister("globChNom");
session_unregister("globChTyp");
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : change de table.",2);
}

//test
//echo "base $datab
";
//echo "table $table
";
//

if (!isset($datab)) {
//lecture des tables disponibles et tri selon rang de l'utilisateur, puis prisentation du choix
if ($sess_admin=="1") {
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($dbGenerale,$linkID) or die ("bad select DB ".mysql_error());
$query="show databases;";
$result=mysql_query($query,$linkID) or die ("bad query get databases in $dbHost. ".mysql_error());
while ($res=mysql_fetch_array($result)) $globDatab[]=$res[0];
} else { // valeurs par difaut
$datab=$dbGenerale;
} // liste des tables disponibles
// formulaire avec prisentation des choix possibles
echo "<HR><font color=red>Htte : $dbHost</FONT>
";
echo "<FORM METHOD=\"POST\" ACTION=$PHP_SELF>"; // ENCTYPE=\"multipart/form-data\">";
echo "<SELECT name=datab>"; // ni multiple ni size=
for ($i=0;$i<count($globDatab);$i++) {
echo "<option value=\"".$globDatab[$i]."\">".$globDatab[$i]."</option>";
} // for affichage
//VGR22102001 FIXed missing /tags (closing) - Netscape is stricter than IE (twice here, cf also gestDB and msgpriv)
echo"</select>";
echo "<INPUT border=0 TYPE=submit NAME=\"getDB\" VALUE=\"Get\">&nbsp;&nbsp;
"; // bouton Load par difaut
echo "</FORM>";
echo "</BODY></HTML>";
exit;
} // else la table est connue

if (!isset($table)) { //) or ($table=='zobi')) {
//lecture des tables disponibles et tri selon rang de l'utilisateur, puis prisentation du choix
if ($sess_admin=="1") {
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
$query="show tables;";
$result=mysql_query($query,$linkID) or die ("bad query get tables in $datab. ".mysql_error());
while ($res=mysql_fetch_array($result)) $globTables[]=$res[0];
} else { // valeurs par difaut
$globTables[]='prives';
$globTables[]='upload';
} // liste des tables disponibles
// formulaire avec prisentation des choix possibles
echo "<HR><font color=red>Database : $datab</FONT>
";
echo "<FORM METHOD=\"POST\" ACTION=$PHP_SELF>"; // ENCTYPE=\"multipart/form-data\">";
echo "<SELECT name=table>"; // ni multiple ni size=
for ($i=0;$i<count($globTables);$i++) {
echo "<option value=\"".$globTables[$i]."\">".$globTables[$i]."</option>";
} // for affichage
//VGR22102001 FIXed missing /tags (closing) - Netscape is stricter than IE (twice here, cf also gestDB and msgpriv)
echo"</select>";
echo "<input type=hidden name=datab value=$datab>";
echo "<INPUT border=0 TYPE=submit NAME=\"getTable\" VALUE=\"Get\">&nbsp;&nbsp;
"; // bouton Load par difaut
echo "</FORM>";
echo "</BODY></HTML>";
exit;
} // else la table est connue

echo "<HR><font color=red>Database : $datab</FONT>&nbsp;&nbsp;&nbsp;<a href=\"$SCRIPT_NAME?change=1\">Changer</A>
";

// on dicrit la table si ce n'est dij` fait
//pri-requis : pas de flottants, premier champ est la clef d'acchs, les types de champ sans longueur sont datetime=19chars et text=>textarea
// : le seul champ permettant un tri limiti ` 2000 est dateheure (donc pas activiti)
if (!isset($globTableLue)) {
//trace de test
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : analyse $table.",7);
//
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
$query="describe $table;";
$globNbChamps=0;
$globLimited=FALSE;
$result=mysql_query($query,$linkID) or die ("bad query get description of $table in $datab. ".mysql_error());
while ($res=mysql_fetch_array($result)) {
$globChNom[]=$res[0]; // "Field"
if($res[0]=='dateheure') $globLimited=TRUE;
$globChTyp[]=$res[1]; // "Type"
// REM on laisse tomber les colonnes suivantes ("Extra" e{t iti intiressant)
$pos1=strpos($res[1],'int'); // suppose qu'il n'y a pas de flottants
$boolPasTrouve=($pos1===false); // vrai si trouvi (via NOT pastrouvi) (pas d'autre solution)
$globChAcc[]=(!$boolPasTrouve)?0:1; // on mimorise que c'est un numirique (pas de ' en requhte)
$longueur=19; // difaut
$pos1=strpos($res[1],'('); // suppose qu'il n'y a pas de flottants
$boolPasTrouve=($pos1===false); // vrai si trouvi (via NOT pastrouvi) (pas d'autre solution)
if (!$boolPasTrouve) { // trouvi
$pos2=$pos1+1;
while ($res[1][$pos2]<>')') $pos2++;
$subchaine=substr($res[1],$pos1+1,$pos2-1-$pos1); // le 3hme par est la longueur pas la position...
$longueur=(integer)$subchaine;
} // if longueur
$globChLon[]=$longueur;
$globNbChamps++;
} //while champs de la table
// le premier champ est implicitement la clef...
$globTableLue=1;
session_register("table");
session_register("globTableLue");
session_register("globLimited");
session_register("globChNom");
session_register("globChTyp");
session_register("globChAcc");
session_register("globChLon");
session_register("globNbChamps");
} // else c'est dij` fait


//
// ----------------------------- LIGNES --------------------------------
//

if (isset($new)) { // positionnis : formulaire
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
$query="replace into $table values (";
for ($i=0;$i<($globNbChamps-1); $i++)
if ($globChAcc[$i]==1) $query.="'".${'F'.$globChNom[$i]}."',"; else $query.=${'F'.$globChNom[$i]}.",";
if ($globChAcc[$globNbChamps-1]==1) $query.="'".${'F'.$globChNom[$globNbChamps-1]}."'"; else $query.=${'F'.$globChNom[$globNbChamps-1]};
$query.=");";
//test
echo "query add = $query
";
//
$result=mysql_query($query,$linkID) or die ("bad query replace in $table $query. ".mysql_error());
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : ajoute via $query.",4);
} // new case

if (isset($get)) {
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
$query="select * from $table where ".$globChNom[0]."=";
if ($globChAcc[0]==1) $query.="'";
$query.=${'F'.$globChNom[0]};
if ($globChAcc[0]==1) $query.="'";
$query.=";";
//test
//echo "query get = $query
";
//
$result=mysql_query($query,$linkID) or die ("bad query get $table ID=".$globChNom[0]." . ".mysql_error());
$res=mysql_fetch_array($result);
//test
//echo $res[0]." ".$res[1]." ".$res[2]." ".$res[3]." ".$res[4]." ".$res[5]." ".$res[6]."
";
//
for ($i=0;$i<$globNbChamps; $i++) {
${'loc'.$globChNom[$i]}=$res[$globChNom[$i]];
//test
//echo "$i ".$globChNom[$i]."=".$res[".$globChNom[$i]."]."
";
//echo "$i loc=".${'loc'.$globChNom[$i]}."
";
//
} // for de chargement
echo "a lu enregistrement ".${'F'.$globChNom[0]}."
";
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : lit via $query.",4);
}

//VGR22112001 ADDed special code for options des sondages, disoli...
if (isset($del)) {
$FID=${'F'.$globChNom[0]};
if ($FID<>'') {
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
$query="delete from $table where ".$globChNom[0]."=";
if ($globChAcc[0]==1) $query.="'";
$query.=$FID;
if ($globChAcc[0]==1) $query.="'";
//VGR22112001 FIXed bug
if ($table==$dbTableOptions) {
$FID2=${'F'.$globChNom[1]};
$query.=" and ".$globChNom[1]."=";
if ($globChAcc[1]==1) $query.="'";
$query.=$FID2;
if ($globChAcc[1]==1) $query.="'";
} // if options des sondages
//EoFix
$query.=";";
//test
//echo "query del = $query
";
//
$result=mysql_query($query,$linkID) or die ("bad query del $FID . ".mysql_error());
echo "a effaci enregistrement $FID
";
LogAction($sess_pseudo,$REMOTE_ADDR,"DB : a effaci via $query.",4);
} else echo "
rien ` effacer
";
}


echo "<HR><font color=red>Formulaire de modification de la table $table</FONT>&nbsp;&nbsp;&nbsp;<a href=\"$SCRIPT_NAME?change2=1&datab=$datab\">Changer</A>
";
echo "<FORM METHOD=\"POST\" ACTION=\"$SCRIPT_NAME\">"; //VGR23062002 ENCTYPE=\"multipart/form-data\"
echo "ID=".$globChNom[0].' '.$globChTyp[0]."&nbsp;".(($globChAcc[0]==1)?'texte':'numirique')."&nbsp;<INPUT border=0 TYPE=text NAME=F".$globChNom[0]." VALUE=\"".${'loc'.$globChNom[0]}."\" SIZE=".Max($globChLon[0],9)." MAXLENGTH=".$globChLon[0].">&nbsp;"; // l'ID
echo "<INPUT border=0 TYPE=submit NAME=get VALUE=\"Get\">&nbsp;&nbsp;<INPUT border=0 TYPE=submit NAME=new VALUE=\"Add/Mod\">&nbsp;&nbsp;<INPUT border=0 TYPE=submit NAME=del VALUE=\"Del\">
"; // bouton Load par difaut
echo "<INPUT TYPE=hidden NAME=globTableLue VALUE=$globTableLue>";
echo "<INPUT TYPE=hidden NAME=table VALUE=$table>";
echo "<input type=hidden name=datab value=$datab>";
echo "<TABLE>";
echo "<tr><td>nom champ</td><td>type</td><td>genre</td><td>valeur</td></tr>";
for ($i=1; $i<$globNbChamps; $i++){ // on saute le 0 qui est ci-dessus
if ($globChTyp[$i]=='text') echo "<TR><TD>".$globChNom[$i]."</td><TD>".$globChTyp[$i]."</td><TD>".(($globChAcc[$i]==1)?'texte':'numirique')."</td><TD><TEXTAREA NAME=F".$globChNom[$i]." ROWS=6 COLS=60 WRAP=\"soft\" MAXLENGTH=400>".${'loc'.$globChNom[$i]}."</TEXTAREA></td></tr>";
else echo "<TR><TD>".$globChNom[$i]."</td><TD>".$globChTyp[$i]."</td><TD>".(($globChAcc[$i]==1)?'texte':'numirique')."</td><TD><INPUT border=0 TYPE=text NAME=F".$globChNom[$i]." VALUE=\"".${'loc'.$globChNom[$i]}."\" SIZE=".Min($globChLon[$i],70)." MAXLENGTH=".$globChLon[$i]."></td></tr>";
} // for d'affichage des autres champs
echo "</TABLE>";
echo "</FORM>";
echo "<HR>";

// listage
echo "<TABLE border=1>";
echo "<tr>";
for ($i=0; $i<$globNbChamps; $i++) echo "<td>".$globChNom[$i]."</td>";
echo "</tr>";
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
//construction requhte
$query="select * from $table";
if ($sess_admin=="1") $query.=" where 1=1"; else {
if ($table=='prives') $query.=" where auteur='$sess_pseudo' or destinataire='$sess_pseudo'";
if ($table=='upload') $query.=" where auteur='$sess_pseudo' or destinataire='$sess_pseudo'"; // like???
} // cas else, spicial utilisateur normal
if ($globLimited) $query.=" order by dateheure desc limit 20;"; // 20 ou 2000 ??? ;-)
else $query.=" order by ".$globChNom[0]." desc limit 20;";
//suite
//test
//echo "query get = $query
";
//
$result=mysql_query($query,$linkID) or die ("bad query get $table listing . ".mysql_error());
while ($res=mysql_fetch_array($result)) {
echo "<tr>";
for ($i=0; $i<$globNbChamps; $i++) echo "<td>".$res[$globChNom[$i]]."</td>";
echo "</tr>";
} // while de parcours
echo "</TABLE>";

echo "</BODY></HTML>";
?>

By: VGR Date: 12/05/2003 17:44:00 English  Type : Comment
interesting extracts :
1) analyse a given table :

//
$linkID=mysql_connect("$dbHost","$dbLogin","$dbPassword") or die ("bad connect".mysql_error());
mysql_select_db($datab,$linkID) or die ("bad select DB ".mysql_error());
$query="describe $table;";
$globNbChamps=0;
$globLimited=FALSE;
$result=mysql_query($query,$linkID) or die ("bad query get description of $table in $datab. ".mysql_error());
while ($res=mysql_fetch_array($result)) {
$globChNom[]=$res[0]; // "Field"
if($res[0]=='dateheure') $globLimited=TRUE;
$globChTyp[]=$res[1]; // "Type"
// REM on laisse tomber les colonnes suivantes ("Extra" eût été intéressant)
$pos1=strpos($res[1],'int'); // suppose qu'il n'y a pas de flottants
$boolPasTrouve=($pos1===false); // vrai si trouvé (via NOT pastrouvé) (pas d'autre solution)
$globChAcc[]=(!$boolPasTrouve)?0:1; // on mémorise que c'est un numérique (pas de ' en requète)
$longueur=19; // défaut
$pos1=strpos($res[1],'('); // suppose qu'il n'y a pas de flottants
$boolPasTrouve=($pos1===false); // vrai si trouvé (via NOT pastrouvé) (pas d'autre solution)
if (!$boolPasTrouve) { // trouvé
$pos2=$pos1+1;
while ($res[1][$pos2]<>')') $pos2++;
$subchaine=substr($res[1],$pos1+1,$pos2-1-$pos1); // le 3ème par est la longueur pas la position...
$longueur=(integer)$subchaine;
} // if longueur
$globChLon[]=$longueur;
$globNbChamps++;
} //while champs de la table








By: VGR Date: 12/05/2003 17:44:00 English  Type : Comment
2) how to display a generic FORMulaire to modify any given table :

echo "<HR><font color=red>Formulaire de modification de la table $table</FONT>&nbsp;&nbsp;&nbsp;<a href=\"$SCRIPT_NAME?change2=1&datab=$datab\">Changer</A>
";
echo "<FORM METHOD=\"POST\" ACTION=\"$SCRIPT_NAME\">"; //VGR23062002 ENCTYPE=\"multipart/form-data\"
echo "ID=".$globChNom[0].' '.$globChTyp[0]."&nbsp;".(($globChAcc[0]==1)?'texte':'numérique')."&nbsp;<INPUT border=0 TYPE=text NAME=F".$globChNom[0]." VALUE=\"".${'loc'.$globChNom[0]}."\" SIZE=".Max($globChLon[0],9)." MAXLENGTH=".$globChLon[0].">&nbsp;"; // l'ID
echo "<INPUT border=0 TYPE=submit NAME=get VALUE=\"Get\">&nbsp;&nbsp;<INPUT border=0 TYPE=submit NAME=new VALUE=\"Add/Mod\">&nbsp;&nbsp;<INPUT border=0 TYPE=submit NAME=del VALUE=\"Del\">
"; // bouton Load par défaut
echo "<INPUT TYPE=hidden NAME=globTableLue VALUE=$globTableLue>";
echo "<INPUT TYPE=hidden NAME=table VALUE=$table>";
echo "<input type=hidden name=datab value=$datab>";
echo "<TABLE>";
echo "<tr><td>nom champ</td><td>type</td><td>genre</td><td>valeur</td></tr>";
for ($i=1; $i<$globNbChamps; $i++){ // on saute le 0 qui est ci-dessus
if ($globChTyp[$i]=='text') echo "<TR><TD>".$globChNom[$i]."</td><TD>".$globChTyp[$i]."</td><TD>".(($globChAcc[$i]==1)?'texte':'numérique')."</td><TD><TEXTAREA NAME=F".$globChNom[$i]." ROWS=6 COLS=60 WRAP=\"soft\" MAXLENGTH=400>".${'loc'.$globChNom[$i]}."</TEXTAREA></td></tr>";
else echo "<TR><TD>".$globChNom[$i]."</td><TD>".$globChTyp[$i]."</td><TD>".(($globChAcc[$i]==1)?'texte':'numérique')."</td><TD><INPUT border=0 TYPE=text NAME=F".$globChNom[$i]." VALUE=\"".${'loc'.$globChNom[$i]}."\" SIZE=".Min($globChLon[$i],70)." MAXLENGTH=".$globChLon[$i]."></td></tr>";
} // for d'affichage des autres champs
echo "</TABLE>";
echo "</FORM>";
By: VGR Date: 12/05/2003 17:53:00 English  Type : Comment
you see ? This technique can also be used to display a "search in table" FORM
By: gvector1 Date: 12/05/2003 17:58:00 English  Type : Comment
I will print out the code and look over it the next little while. I will have to freshen up on PHP, I'm not too familiar with it. I appreciate all of your insight, I awarded you the points for you help. From the sounds of it, I could use that "search in table" form technique.

Thanks again
Kendal
By: VGR Date: 12/05/2003 18:08:00 English  Type : Comment
The code should translate in C/C++, PHP is very close to Java and them and even uses synonymic functions.

Do register to be able to answer

EContact
browser fav
page generated in 371.428010 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page