You guys were sooOOOOOooo helpful - I wanted to preg_match the purpose statments from the contents I pull from a file with SQL statements... .so for example - the first match is
purpose == "SHOW ALL TABLES"
The file contents, which I read into a variable is shown below.
Honestly - I tried to modify the code you provided for me yesterday.... but I just don't get it. Even after reading http://www.regular-expressions.info/quickstart.html through fifteen times.
Any Help Would be Appreciated
VmusicV
------------------------------'text' I'm searching through below-------------------------------
Code: Select all
<?
/////////////////////////////////////////////////////////////////////////////////////////
//function to get data
function getData($request_page, $table_view, $filter, $order, $purpose)
{
global $mysql_errno, $mysql_error, $no_db_connection, $no_result;
//build sql statement based on the table -
//for complex data sets test for and include $filter and $order
switch($table_view)
{
case $table_view :
{ //list of all tables from the passed in databasse
if($purpose == "SHOW ALL TABLES") //keep the format and spacing for $purpose EXACT
{
$sql_statement = "SHOW TABLES FROM $table_view";
$script_error = " retrieving a list of all tables in the database";
}
elseif($purpose == "SHOW COLUMNS") //keep the format and spacing for $purpose EXACT
{
$sql_statement = "SHOW COLUMNS FROM $table_view";
$script_error = " retrieving a list of columns for the table or view $table_view";
}
break;
}
case "sys_element_attribute_spec" :
{
if($purpose == "SHOW ALL FORM ELEMENTS and ATTRIBUTES") //keep the format and spacing
{
$sql_statement = "SELECT seas.* FROM `sys_element_attribute_spec` seas $filter $order";
$script_error = " retrieving a list of elements and their attribute specifications";
//reportError($request_page, $script_error , $purpose , $sql_statement);
}
else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
{
$sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
$script_error = " Retrieving hyper link order or arrangement on page";
}
//reportError($request_page, $script_error , $purpose , $sql_statement);
break;
}
case "sys_form_specification" :
{
if($purpose == "SHOW ALL FORM SPECIFICATIONS")//keep the format and spacing for $purpose
{
$sql_statement = "SELECT fp.*, FROM `sys_form_specification` $filter $order";
$script_error = " retrieving list of form specifications";
//reportError($request_page, $script_error , $purpose , $sql_statement);
}
else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
{
$sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
$script_error = " Retrieving hyper link order or arrangement on page";
}
//reportError($request_page, $script_error , $purpose , $sql_statement);
break;
}
case "party": //keep the format and spacing for $purpose EXACT
{
if($purpose == "PARTY AND IMAGES REGARDLESS of ROLE")
{
$sql_statement = "SELECT p.party_id, p.party_type, p.person_fnm, p.person_mnm, p.person_lnm, p.org_nm, p.tagline, p.address_ln1, p.address_ln2, p.address_city, p.address_state, p.address_zip, p.phone1, p.phone1_type, p.phone2, p.phone2_type, p.email, p.website, i.image_file_nm, p.img_file_nm, p.map_img_file_nm, p.login_id, p.login_pwd, p.login_reminder, p.login_last_updated, p.created_user_id, p.created_date_ts, p.last_updated_user_id, p.last_updated_date_ts, p.party_desc FROM be_party p, be_image i $filter $order";
$script_error = " retrieving party and images regardless of role";
//reportError($request_page, $script_error , $purpose , $sql_statement);
}
break;
}
case "content" :
{
if($purpose == "GENERAL DISPLAY") //keep the format and spacing for $purpose EXACT
{
$sql_statement = "SELECT c.*, p.person_fnm, p.person_lnm FROM `content` c, `party_content` pc, `party` p $filter $order";
$script_error = " Retrieving General Display Content/Article and Author(s)";
//reportError($request_page, $script_error , $purpose , $sql_statement);
}
else if ($purpose == "MAX ORDER NUMBER")//keep the format and spacing for $purpose EXACT
{
$sql_statement = "SELECT MAX(link_order) FROM LINKS $filter";
$script_error = " Retrieving hyper link order or arrangement on page";
}
//reportError($request_page, $script_error , $purpose , $sql_statement);
break;
}
} //end of switch
/////////////////////////////////////////////////////////////////////////////////////////
//connect to the db and get the results
$db_link = db_connect();
if(!$db_link)
{
//error handling
reportError($request_page, $script_error, $no_db_connection, $sql_statement);
$result = -1;
}
else
{
// SQL Query - should select each column by name
$result = mysql_query($sql_statement, $db_link);
if(!$result)
{
//error handling
reportError($request_page, $script_error, $no_result, $sql_statement);
$result = -2;
}
return $result;
}
} //end function getData