- 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";
}
}
"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 rowsSELECT Text_Description FROM TextSlide_Table
. and loop through all of them. - Adison Masih