Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:29:34+00:00 2026-06-07T16:29:34+00:00

I have 2 tables : Table document ============================================================================ | id_document | document_address | document_content

  • 0

I have 2 tables :

Table document
============================================================================
| id_document | document_address |              document_content           |
============================================================================
|      1      |        C         |Example sentences A. Example sentences B.|
|      2      |        D         |Example sentences C. Example sentences D.|
============================================================================

I want to separate document_content based on dot and insert them into sentence table with their doc_id so the sentence table will contain :

Table sentence :
 ======================================================================
 |  id_row  |  id_document |   id_sentence   |       sentence         | 
 ======================================================================
 |     1    |       1      |       0         | Example sentences A    |
 |     2    |       1      |       1         | Example sentences B    |
 |     3    |       2      |       0         | Example sentences C    |
 |     4    |       2      |       1         | Example sentences D    |
 ======================================================================

Here’s the code :

<?php

require_once 'conf.php';

$doc_id = array();
// get the doc_id
$result = mysql_query("SELECT id_document FROM document");
while($row = mysql_fetch_array($result)) {
   $doc_id[] = $row['id_document'];
}

//get the content
$sql = mysql_query('SELECT document_content FROM document WHERE id_document IN (' . implode(",", $doc_id) . ')') or die(mysql_error());
while ($row = mysql_fetch_array($sql)) {
   $sentence[] = $row['document_content'];
}

$i = 0;
foreach ($sentence as $sentences){
  // Separate based on dot
  $saveSentence = preg_split('/\\.\\s*/', $sentences);
   $q = mysql_query("INSERT INTO sentence VALUES('','$doc_id','$i','$saveSentence','') ");
$i++;
}

?>

but the doc_id cannot be read and the array of content cannot be inserted to table. Help me please. thank you very much : )

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:29:36+00:00Added an answer on June 7, 2026 at 4:29 pm

    you didn’t fetch doc_id
    replace

    $sql = mysql_query('SELECT document_content FROM document WHERE id_document IN (' . implode(",", $doc_id) . ')') or die(mysql_error());
    while ($row = mysql_fetch_array($sql)) {
       $sentence[] = $row['document_content'];
    }
    
    $i = 0;
    foreach ($sentence as $sentences){
    // Separate based on dot
      $saveSentence = preg_split('/\\.\\s*/', $sentences);
       $q = mysql_query("INSERT INTO sentence VALUES('','$doc_id','$i','$saveSentence','') ");
    $i++;
    }
    

    with

    $sql = mysql_query('SELECT id_document, document_content FROM document WHERE id_document IN (' . implode(",", $doc_id) . ')') or die(mysql_error());
    while ($row = mysql_fetch_array($sql))
    {
       $sentence[$row['id_document']] = $row['document_content'];
    }
    
    foreach ($sentence as $doc_id => $sentences)
    {
      $i = 0;
      foreach(preg_split('/\\.\\s*/', $sentences) as $current_sentence)
      {
        $q = mysql_query("INSERT INTO sentence SET id_document = {$doc_id}, id_sentence = {$i}, sentence = '{$current_sentence}'");
        $i++;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large table I want to include in a LaTeX document. It
I'm using tables in my document, and I want to be able to have
I have two tables document (id, file) similarity(id1,id2,similarityvalue) where id1 and id2 are foreign
I have a classified_id variable which matches one document in a MySql table. I
I have two tables: Agents with columns: agentid, name DocumentsRead with columns: agentid, document,
If I have a table structure like this: Transaction [TransID, ...] Document [DocID, TransID,
I have an HTML document where I have two different tables. One is class
I have two tables: account_company and document_invoice. Table account_company has 2 columns: company_id and
I have the following problem: I have 3 tables: If you want to create
I have a problem with jquery and a dynamic table. I want a click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.