How can I reduce lines of code per file?
Posted: Thu Oct 05, 2006 4:20 pm
All over one of my files (profile.php) I have database query's in the form of:
and Is there a way to just throw each one of these into a file and call that file each time I need the specific query run?
I mean there are all kinds of querys on tables such as friends, loginphp, profile_photo, wall, education, general and having to constantly add in the query is annoying, I would like to have a master file of my database query's and be able to call the one I want when I want it to reduce lines of code in my files, and eliminate the need for me to type in the query's over and over.
Thanks
-Steve
Code: Select all
$result = mysql_query("SELECT * FROM loginphp WHERE Uname='{$_SESSION[Uname]}'") or die(mysql_error());
$row = mysql_fetch_array( $result );Code: Select all
$result = mysql_query("SELECT * FROM friends WHERE global_id='$_GET[id]' AND friend_global_id='$global_id'") or die(mysql_error());
$num_rows = mysql_num_rows($result);I mean there are all kinds of querys on tables such as friends, loginphp, profile_photo, wall, education, general and having to constantly add in the query is annoying, I would like to have a master file of my database query's and be able to call the one I want when I want it to reduce lines of code in my files, and eliminate the need for me to type in the query's over and over.
Thanks
-Steve