Content about Java ERP Solution for Reviews Best ERP Software for sale and Free Software with Java OpenSource for Free Download
Showing posts with label Developer PHP. Show all posts
Showing posts with label Developer PHP. Show all posts

PHP Remove HTML Tag Cleaning Text

We can parse HTML page to collect only normal text with PHP function  strip_tags()
for example to using this functoin in bilow

Example to using  PHP strip_tags()

    $html_page="<a href='test.php'>This is my page </a>";  
   $txt.=strip_tags($html_page);  

The output is return
This is my page yes

Note** If we have complex HTML page the output is not perfect we need to clean it self for example
   $description.=" ".strip_tags(trim($html_page))." ".$main_term;  
   $description = ereg_replace( "\n", " ", $description);  
   $description = ereg_replace( "\r", " ", $description);  
   $description = ereg_replace( " ", " ", $description);  
   $description = ereg_replace( " ", " ", $description);  
   $description = ereg_replace( " ", " ", $description);  
   $description = ereg_replace( " ", " ", $description);  

PHP mysql tutorial example to manage mysql database with PHP

Mysql is the most popular free DBMS with high performance we can use PHP to manage MySQL with query , insert , delete , update
This tutorial is basis for using PHP to execute SQL command pass to MySQL DBMS

PHP MySQL tutorial

 //Connect database  
 $username="root";  
 $password="root";  
 $database="testdb";  
 mysql_connect("localhost",$username,$password);  
 @mysql_select_db($database) or die( "Unable to select database");  
 //SQL Query command  
 $query="select * from my_table where p_type='Y' order by last_view desc limit 0,10";  
 $result=mysql_query($query);  
 $x_num=mysql_numrows($result);  
 $x_i=0;  
 while ($x_i < $x_num) {  
   $code=mysql_result($result,$x_i,"code_id");  
   $title=mysql_result($result,$x_i,"title");  
   echo "<BR>".$code." : ".$title;  
 }  
 //SQL Insert / Update Command by using only mysql_query();  
 $query = "insert into test_comment (flash_id,content,post_by,create_date,last_update,ip) ";  
 $query.="values('$flash_id','$content2','$post_by','$_date','$_date','$ip')";  
 mysql_query($query);  
 $query = "update test_table set stat=$new_stat,last_view='$last_view' where code_id=$code_id";  
 mysql_query($query);  

Tip : you can using command mysql_query(); to execute SQL command to mysql it's very easy yes

PHP Mysql tutorial for beginners with examples code and tip

PHP Mysql tutorial for beginners with examples code and tip for query with select commans ,
insert delete update with mysql_query();

Example PHP Mysql for Connect Database  (PHP Mysql tutorial for beginners)
you can use function mysql_connect(); to connect to mysql dbms by send db host , db user , db password
and use function mysql_select_db(); to connect to databalse by send database name for example

$username="dbuser";
$password="dbpassword";
$database="mydatabase";
mysql_connect("localhost",$username,$password);
//select database if fail print error
@mysql_select_db($database) or die( "Unable to select database");


Example PHP Mysql for Query with SQL command  (PHP Mysql tutorial for beginners)
you can execute any SQL command by sending parameter to functoin mysql_query();
for example in query it's will return data in mysql_result();

 
$query="select *  from test_comment where flash_id='$code_id' order by comment_id desc";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
    $content =mysql_result($result,$i,"content");
    echo "
".$content;
}

 
Example PHP Mysql for Insert with SQL command  (PHP Mysql tutorial for beginners)
for Insert mode it's easy way to using function mysql_query(); to execute SQL command with insert statement  example code in below

$query = "insert into test_comment (flash_id,content,post_by,create_date,last_update,ip) ";
$query.="values('$flash_id','$content2','$post_by','$_date','$_date','$ip')";
mysql_query($query);

Example PHP Mysql for Delete with SQL command  (PHP Mysql tutorial for beginners)
for delete mode it's the same way by using mysql_query();  example code in below\

$query = "delete from  test_comment ";
mysql_query($query);

Example PHP Mysql for Update with SQL command  (PHP Mysql tutorial for beginners)
for update mode it's the same yes

$query = "update test_comment  set title='test' where code_id='1001'";
mysql_query($query);

Tip : With PHP and MySQL you can only using mysql_query();  you can send any SQL command to execute wink