Query the database PHP


/ Published in: PHP
Save to your folder(s)

To use:
$update_sql = querys($sql);
or
$select_sql = getresult($sql);

Used simplify selecting rows from a database. You'll need to pass in the SQL statement.


Copy this code and paste it in your HTML
  1. /*FUNCTION: querys
  2.  *PURPOSE: querys the database
  3.  *RETURNS: $rs - result set
  4.  */
  5. function querys($sql){
  6. $rs=mysql_query($sql);
  7. return $rs;
  8. }
  9. /*FUNCTION: get result
  10.  *PURPOSE: querys the database, adds to assicoative array
  11.  *REUTRNS: $data - assocative array
  12.  */
  13. function getresult($sql){
  14. $rs=mysql_query($sql);
  15. $data=@mysql_fetch_array($rs);
  16. return $data;
  17. }

URL: linkdeo.net

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.