2012-05-08 1 views
0

PHP 코드가있는 도움말 파일을 MySql 데이터베이스에로드 하시겠습니까?

그것이

로 표시 나는 "ALT + 0" 을 누르면 내가 ++ 때문에 메모장에서 위의 형식을 사용
//Filename:PHP_Help.html 

<!-- Heading of the Issue/Solution 

// it may contain PHP Code or Mysql Queries or General Description 
<?php 

    // Code that fixed the issue/ Solution to a problem 
?> 

Some general Description 
--> 

다음 구문을 메모장 ++ 에서 만든 도움말 파일이
<!-- Heading of issue 1 
<!-- Heading of issue 2 

그래서 제목을 읽는 문제에 대한 해결책을 찾는 데 도움이됩니다. 도움말 파일의 크기가 증가 문제

그래서 데이터베이스에 파일을로드하고 문제/솔루션

를 검색 할 PHP를 사용하려고 수백을 포함하고있다 그러나

내 데이터베이스 스키마는

같은 것
Create table issues 
(
id int auto_increment primary key, 
header nvarchar(100), 
content text 
); 

내 질문은 어떻게 데이터베이스에 특정 파일을로드합니까?

답변

0
// Read the file into a php variable: 
$filecontents = file_get_contents ("PHP_Help.html"); 

// explode the string into individual records: 
$records = explode ("<!--" , $filecontents); 

// work through the array of records: 
foreach($records as $record) { 
    // find your first linefeed 
    $headingend = strpos($record, chr(13)); 
    // get the heading 
    $heading = substr($record, 0, $headingend); 
    // and the content 
    $content = substr($record, $headingend); 
    // write to the database... 
} 
관련 문제