I'm using wordpress and into the content of pages i use a PHP code to send query to database and print result of that to the page, and now from in database i have many columns that one of them is a URL of a picture. in PHP code how can i show the picture on a page ? this is my following code and it's not clean :D and also i use INSERT PHP plugin for wordpress to insert the PHP code in content of a page:
[insert_php]
global $wpdb;
$wpdb->show_errors();
$pr = get_the_title();
$results = $wpdb->get_results("SELECT * from print_drug where Product_Name = '".$pr."'");
foreach ($results as $obj) {
echo "<em><strong>Product Name:</strong></em> "; print_r($obj->Product_Name); echo "<br>";
echo "<em><strong>Active Substance:</strong></em> "; print_r($obj->Active_Substance); echo "<br>";
echo "<em><strong>Substance Sorting Identification Number:</strong></em> "; print_r($obj->Substance_Sorting_Identification_Number); echo "<br>";
echo "<em><strong>Production Form of Use:</strong></em> "; print_r($obj->Production_Form_of_Use); echo "<br>";
echo "<em><strong>Chemical Formation:</strong></em> "; print_r($obj->Chemical_Formation); echo "<br>";
echo "<em><strong>Dosages of Use:</strong></em> "; print_r($obj->Dosages_of_Use); echo "<br>";
echo "<em><strong>Approval Agency:</strong></em> "; print_r($obj->Approval_Agency); echo "<br>";
echo "<em><strong>Year of Approval:</strong></em> "; print_r($obj->Year_of_Approval); echo "<br>";
echo "<em><strong>Approval Assigned Company:</strong></em> "; print_r($obj->Approval_Assigned_Company); echo "<br>";
echo "<em><strong>Approval Country:</strong></em> "; print_r($obj->Approval_Country); echo "<br>";
echo "<em><strong>Prohibited Cases:</strong></em> "; print_r($obj->Prohibited_Cases); echo "<br>";
}
[/insert_php]
and then i there any way to clean this code ? i'm new in PHP :)
See Question&Answers more detail:os