Possible Duplicate:
PHP file cannot enter some part of code
I am building a news website and I have a function file, for all functions but, nearly all the functions made the same way as the below example:
function one(){
$query = "SELECT * FROM table WHERE id='$id'....";
$result = mysql_query($query);
while($row=mysql_num_rows($result))
{echo "$row[data]";} }
So, basically there are many functions that serve different purpose, but have the same exact template as the above, So, to save time, codding I was thinking if is would be possible, to simplify the 5 lines? to one with function like:
function(something here, and here){then the result here?}
Since the only thing that may change from the first code are: Select, table names, id, and the $row[data], and everything will remain the same what if I assign those to variables and the rest structure will stay as it is in a function:
check this idea.
function simplify() {
$query = "$crud * FROM $table WHERE id= '$id' ";
$result = mysql_query($query);
while($row=mysql_fetch_array($result)) {echo "$row[data]";}
}
So anytime, I need to create the first code, I could just do
echo simlify(and here would be table name, id, select, create, update...) {
and here the result}
So sorry, for asking this complex question, or asking it with complexity but If anyone has any idea, about what I am talking about, I need your help.