I have a database with a LOT of fields. I need to have a function for each field like this:
function S_00_CP_J_ABVV ($zoekcriteria) {
db();
$query = "SELECT S_00_CP_J_ABVV FROM svbedrijf" . $searchcriteria;
$queryexe = mysql_query ($query);
$S_00_CP_J_ABVV = 0;
while ($row = mysql_fetch_row($queryexe)) {
$S_00_CP_J_ABVV = $S_00_CP_J_ABVV + $row[16];
}
echo $S_00_CP_J_ABVV;
db_close();
unset($query);
unset($queryexe);
unset($row);
}
As you might have guessed the strange name (S_00_CP_J_ABVV) is the field name. As I need exactly the same function for every field, I wondered if there wasn't a quick way to code instead of typing the above function again and again with only some varieties (function name = name of field, $S_00_CP_J_ABVV, and the number of the row ($row[16])?You could use classes and use subclasses to overwrite certain parts of the parent class. At least I think you canhmmm... Try this tutorial on phpfreaks:
<!-- m --><a class="postlink" href="http://www.phpfreaks.com/tutorials/48/0.phpOriginally">http://www.phpfreaks.com/tutorials/48/0.phpOriginally</a><!-- m --> posted by friday
As you might have guessed the strange name (S_00_CP_J_ABVV) is the field name. As I need exactly the same function for every field, I wondered if there wasn't a quick way to code instead of typing the above function again and again with only some varieties (function name = name of field, $S_00_CP_J_ABVV, and the number of the row ($row[16])?
WHY??? why are you doing it that way. right one function and send the field name to it instead. you do not need a function for every field name.
function S_00_CP_J_ABVV ($zoekcriteria) {
db();
$query = "SELECT S_00_CP_J_ABVV FROM svbedrijf" . $searchcriteria;
$queryexe = mysql_query ($query);
$S_00_CP_J_ABVV = 0;
while ($row = mysql_fetch_row($queryexe)) {
$S_00_CP_J_ABVV = $S_00_CP_J_ABVV + $row[16];
}
echo $S_00_CP_J_ABVV;
db_close();
unset($query);
unset($queryexe);
unset($row);
}
As you might have guessed the strange name (S_00_CP_J_ABVV) is the field name. As I need exactly the same function for every field, I wondered if there wasn't a quick way to code instead of typing the above function again and again with only some varieties (function name = name of field, $S_00_CP_J_ABVV, and the number of the row ($row[16])?You could use classes and use subclasses to overwrite certain parts of the parent class. At least I think you canhmmm... Try this tutorial on phpfreaks:
<!-- m --><a class="postlink" href="http://www.phpfreaks.com/tutorials/48/0.phpOriginally">http://www.phpfreaks.com/tutorials/48/0.phpOriginally</a><!-- m --> posted by friday
As you might have guessed the strange name (S_00_CP_J_ABVV) is the field name. As I need exactly the same function for every field, I wondered if there wasn't a quick way to code instead of typing the above function again and again with only some varieties (function name = name of field, $S_00_CP_J_ABVV, and the number of the row ($row[16])?
WHY??? why are you doing it that way. right one function and send the field name to it instead. you do not need a function for every field name.