Hi There!

I'm Seeking for a Function by which I can Execute mySQL Queries for any table.

Recommended Answers

All 3 Replies

Hello,
Best way i think to do do database operation is:

/* Define database settings */
define('db_user', '[I]database username goes here[/I]');
define('db_pass', '[I]database password goes here[/I]');
define('db_name', '[I]database name goes here[/I]');

// connect to the database
function openMysql(){
	mysql_connect("localhost", db_user, db_pass) or die("Could not connect to the server: " . mysql_error());
	mysql_select_db(db_name);	
}

openMysql();

$sql = "SELECT * FROM [I]table name[/I]";
$query = mysql_query($sql);
$row = mysql_fetch_assoc($query);

Hope that helps.

Thanks,
Marais

Hello,
Best way i think to do do database operation is:

/* Define database settings */
define('db_user', '[I]database username goes here[/I]');
define('db_pass', '[I]database password goes here[/I]');
define('db_name', '[I]database name goes here[/I]');

// connect to the database
function openMysql(){
	mysql_connect("localhost", db_user, db_pass) or die("Could not connect to the server: " . mysql_error());
	mysql_select_db(db_name);	
}

openMysql();

$sql = "SELECT * FROM [I]table name[/I]";
$query = mysql_query($sql);
$row = mysql_fetch_assoc($query);

Hope that helps.

Thanks,
Marais

what the Hell !

I know it that i can execute mysql queries by mysql function but i need a php function by which i can execute mysql functions

something like

function exeQuery($table, $condition, $limit, ......etc){
statements goes here;
}
I hope now you understand What I actually asking for?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.