0

Hi There!

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

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by akvlko
0

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

Edited by scarcella: n/a

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.