Title: including my own php scripts into wordpress
Last modified: August 18, 2016

---

# including my own php scripts into wordpress

 *  [rozilla](https://wordpress.org/support/users/rozilla/)
 * (@rozilla)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/including-my-own-php-scripts-into-wordpress/)
 * i got a php/mysql thing going on at [http://businessdirectory.clickafricana.com/categories.php](http://businessdirectory.clickafricana.com/categories.php)
   
   how do i integrate that into my WP blog?
 * here’s the code i used:
 *     ```
       <?php
   
       $dbh=mysql_connect ("localhost", "<USER>", "<PASSWORD>") or die ('I cannot connect to the database because: ' . mysql_error());
       mysql_select_db ("<DB-NAME>");
   
       // display individual record
   
       if (isset($_REQUEST['category'] ))
       {$category = stripslashes(trim($_REQUEST['category']));
          $result = mysql_query("SELECT * FROM <code>businesses</code> WHERE <code>category</code> = '{$category}' ORDER by bizname;", $dbh);
          $myrow = mysql_fetch_array($result);
          echo "<h2>Category: $category</h2>";
          do
          {
             printf("<p><b>%s</b>\n<br />", $myrow["bizname"]);
             printf("%s\n<br />", $myrow["description"]);
             printf("%s\n<br />", $myrow["address"]);
             printf("%s\n<br />", $myrow["country"]);
             printf("%s\n<br />", $myrow["telephone"]);
             if ($myrow["url"])
               printf("<a href=\"$myrow[7]\" target=\"_blank\">%s</a>\n<br />", $myrow["url"]);
             if ($myrow["email"])
               printf("<a href=\"mailto:$myrow[8]\">%s</a>\n</p><br />", $myrow["email"]);
             echo"<hr>";
           }while($myrow = mysql_fetch_array($result));
       }
       else
       {// show categories list
          $result = mysql_query("SELECT * FROM categories ORDER BY category",$dbh);
          $test = mysql_query("SELECT * FROM businesses ORDER BY bizname",$dbh);
           if ($myrow = mysql_fetch_array($result))
           {// display list if there are records to display
             do
             {
               printf("<a href=\"%s?category=%s\">%s</a><br>\n", $PHP_SELF, $myrow["category"], $myrow["category"]);
             } while ($myrow = mysql_fetch_array($result));
           }
           else
           {// no records to display
             echo "Sorry, no records were found!";
           }
       }
   
       ?>
       ```
   

The topic ‘including my own php scripts into wordpress’ is closed to new replies.

 * In: [Installing WordPress](https://wordpress.org/support/forum/installation/)
 * 0 replies
 * 1 participant
 * Last reply from: [rozilla](https://wordpress.org/support/users/rozilla/)
 * Last activity: [18 years, 9 months ago](https://wordpress.org/support/topic/including-my-own-php-scripts-into-wordpress/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
