<?php
header('Content-Type: text/html; charset=utf-8');
$conn = new mysqli("localhost", "crmsahavasco", "sa123AWEsadfa", "crmsahavasco_arevastockexpsheet");

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$conn->set_charset("utf8mb4");
?><?php

$conn->set_charset("utf8mb4");
mysqli_query($conn,"SET NAMES 'utf8mb4'");
mysqli_query($conn,"SET CHARACTER SET utf8mb4");
mysqli_query($conn,"SET SESSION collation_connection = 'utf8mb4_unicode_ci'");

?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Vishnu Sahasranamam</title>

<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;600&family=Playfair+Display:wght@600&display=swap" rel="stylesheet">

<style>
body {
    margin: 0;
    padding: 0;
    background: linear-gradient(to bottom, #fff8e1, #ffe0b2);
    font-family: 'Noto Sans Devanagari', sans-serif;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 40px auto;
    background: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.title {
    text-align: center;
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: #b71c1c;
    margin-bottom: 20px;
}

.name-number {
    text-align:center;
    font-size:18px;
    color:#6d4c41;
    margin-bottom:15px;
}

.section-title {
    margin-top: 25px;
    font-size: 20px;
    color: #bf360c;
    border-bottom: 2px solid #ffcc80;
    padding-bottom: 5px;
}

.content-block {
    margin-top: 12px;
    font-size: 17px;
    line-height: 1.9;
    color: #333;
}

.highlight {
    color: #d84315;
    font-weight: 600;
}

.shloka {
    text-align: center;
    font-size: 22px;
    color: #4e342e;
    margin-bottom: 20px;
}
p { text-align:justify; }
</style>
</head>

<body>
<a href="download.php">
    <button>Download as Word</button>
</a>

<!-- <div class="title" style="padding-top:10px;">&#2405; &#2357;&#2367;&#2359;&#2381;&#2339;&#2369; &#2360;&#2361;&#2360;&#2381;&#2352;&#2344;&#2366;&#2350; &#2405;</div>
--><div style="
  max-width: 900px;
  margin: 40px auto;
  padding: 50px 60px;
  background: #fdfcf9;
  font-family: 'Georgia', serif;
  line-height: 1.9;
  color: #2c2c2c;
  box-shadow: 0 0 30px rgba(0,0,0,0.08);
  border-radius: 8px;
">

  <!-- Title -->
  <div style="text-align:center; margin-bottom:30px;">
    <h2 style="color:#c75b12; letter-spacing:2px;">॥ श्री विष्णु सहस्रनाम ॥</h2>
    <h1 style="font-size:48px; color:#1f3a63; margin:5px 0;">Vishnu Sahasranama</h1>
    <h2 style="color:#b07a1b; font-style:italic;">Preface</h2>
    <p style="font-style:italic; font-size:18px; max-width:650px; margin:auto; text-align:center">
      A Research and Interpretation Exercise on the<br>
      Vishnu Sahasranama Stotra and Its Significance in Hinduism
    </p>
  </div>

  <!-- Divider -->
  <div style="width:80px; height:2px; background:#c75b12; margin:30px auto;"></div>






</div></div>
<?php 
$sql = "SELECT DISTINCT shlokas FROM vishnu_sahasranamam ORDER BY id ASC";
$result = $conn->query($sql);

if(!$result){
    die("SQL Error: " . $conn->error);
}

while($row1 = $result->fetch_assoc()) {  
    $shlokas = $row1['shlokas'];
?>

 <div class="shloka">
        <?php echo nl2br($row1['shlokas']); ?>
    </div>
<?php 
$stmt = $conn->prepare("SELECT * FROM vishnu_sahasranamam WHERE shlokas = ? ORDER BY id ASC");
$stmt->bind_param("s", $shlokas);
$stmt->execute();
$result1 = $stmt->get_result();
while($row = $result1->fetch_assoc()) { ?>
<div class="container">


   
    <div class="name-number">&#2344;&#2366;&#2350; &#2325;&#2381;&#2352;&#2350;&#2366;&#2306;&#2325;: <?php echo $row['id']; ?></div>

   

    <div class="section-title">&#2350;&#2352;&#2366;&#2336;&#2368; &#2309;&#2352;&#2381;&#2341;</div>

    <div class="content-block">
        <span class="highlight">शब्द:</span><br>
        <?php echo nl2br($row['single_words_marathi']); ?>
</div>

    <div class="content-block">
        <span class="highlight">&#2309;&#2352;&#2381;&#2341;:</span><br>
        <?php echo nl2br($row['meaning_marathi']); ?>
</div>
<div class="content-block">
    <span class="highlight">&#2357;&#2367;&#2357;&#2375;&#2330;&#2344;:</span><br>
    <?php 
    echo preg_replace('/([\.।])\s*(?!<br>)/u', '$1<br>', $row['details_marathi']);
    ?>
</div>

    <div class="section-title">English Meaning</div>

    <div class="content-block">
        <span class="highlight">Name:</span><br>
        <?php echo nl2br($row['single_words_english']); ?>
    </div>

    <div class="content-block">
        <span class="highlight">Simple Meaning:</span><br>
        <?php echo nl2br($row['simple_meaning']); ?>
    </div>

    <div class="content-block">
        <span class="highlight">Mythology / Philosophy / Spiritual:</span><br>
        <?php echo nl2br($row['details_information']); ?>
    </div>

  

</div>

<?php } ?><?php } ?>


</body>
</html>

<?php
$conn->close();
?>