0
votes
  1. How can I select a specific text element from database without putting ID. I have different paragraphs on my HTML and wanna select them from database
    How can I select a specific text element from database without putting ID. I have different paragraphs on my HTML and wanna select them from database

**

function connect() {
    $con=`mysqli`_connect("127.0.0.1","Egli", "","Egli");
    // Check connection
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    } else {
        return $con;
    }
}


function renderContent($con) {
    $sql = "SELECT Text_Description FROM TextSlide_Table WHERE ID=1";
    $result = $con->query($sql);

    if ($con && ($result->num_rows > 0)) 
    {
        // output data of each row
        while($row = $result->fetch_assoc()) 
        {
            echo $row["Text_Description"];
        }
    } else {
         echo "error";
    }
}

function renderContent2($con) {
    $sql = "SELECT Text_Description FROM TextSlide_Table WHERE ID=2";
    $result = $con->query($sql);

    if ($con && ($result->num_rows > 0)) 
    {
        // output data of each row
        while($row = $result->fetch_assoc()) 
        {
            echo $row["Text_Description"];
        }
    } else {
         echo "error";
    }
}
<?php renderContent($con); ?> This is how I call It inside HTML but I want to get a specific text - Eglim22
"without putting ID", if you want to select any specific row in a database, you will need to provide an unique identifier which identifies that row. however from what you have described, I have inferred that you have multiple rows in the database and you want all of them, well for that fetch all the rows SELECT Text_Description FROM TextSlide_Table. and loop through all of them. - Adison Masih
I have like only 3 actually but they are in different divs and I am new in PHP not sure how to do that.Like when I call it in HTML I want to call a specific index from Database - Eglim22