hello,
i wanna know whats the best way to show query results from mysql onto a webpage..
some says this can only be done in form of table..
but nowadays table less design is preferred..tell me teh most demanding way if somebody knows..
hello,
i wanna know whats the best way to show query results from mysql onto a webpage..
some says this can only be done in form of table..
but nowadays table less design is preferred..tell me teh most demanding way if somebody knows..
Quick diagnosis for (and a clarifying note for ): the code stops working primarily because the old mysql_* fetch function is mixed with mysqli_* calls, and several boolean/string checks and unescaped inputs create logic and security problems. Semantically, use a <table> for true tabular data; use cards, lists or CSS Grid/Flexbox for record cards or responsive layouts — either is fine as said, but semantics and accessibility matter.
Immediate fixes and practical tips:
mysql_fetch_array() with mysqli_fetch_assoc() (or use PDO). Always check the query result before looping.if (!empty($region[$i])) or if ($region[$i] !== '') — avoid if(!$region[$i] == "").mysqli_real_escape_string() and whitelist any dynamic table/column names.RADIANS() in SQL or deg2rad() in PHP; the hard-coded 0.01745 is imprecise. Consider the haversine formula or MySQL spatial functions for accuracy and performance.htmlspecialchars() before echoing into HTML.Short example patterns (replace column names as needed):
$result = mysqli_query($con, $s);
if (!$result) { error_log(mysqli_error($con)); echo "Query failed."; }
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>" . htmlspecialchars($row['sno'], ENT_QUOTES, 'UTF-8') . "</td></tr>";
} Or render as cards:
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='card'><h3>" . htmlspecialchars($row['name']) . "</h3><p>"
. htmlspecialchars($row['summary']) . "</p></div>";
} Performance and safety: add LIMIT/pagination, index searchable columns, log DB errors (don’t show them to users), and validate/whitelist table names when they come from a form. These changes should make the query run and the output safe and presentable whether using tables or a tableless layout.
Jump to Post— pritaeas 2,276some says this can only be done in form of table.
It's all up to you, how it would best fit into your design. There is no one guaranteed best way to do this.
Jump to Post— pritaeas 2,276should i make it table less or with table
That would be your decision. Either is just fine.
share code
Share code for what? Did you look at the code snippets in this forum?
some says this can only be done in form of table.
It's all up to you, how it would best fit into your design. There is no one guaranteed best way to do this.
sir i have made design free so page load faster..tell me should i make it table less or with table and share code
should i make it table less or with table
That would be your decision. Either is just fine.
share code
Share code for what? Did you look at the code snippets in this forum?
ya i have seen but not found
i want to show results from mysql to a rtable on a web page..
how can i do this??
i have made thus code but it is not working
if($_POST["results"])
{
$db=$_POST["db"];
$skills = explode(",", $_POST["skills"]);
$table = explode(",", $_POST["table"]);
$city = explode(",", $_POST["city"]);
$region = explode(",", $_POST["region"]);
$country = explode(",", $_POST["country"]);
$latitude=$_POST["lat"];
$longitude=$_POST["long"];
$distance=$_POST["dist"];
$latitude*=0.01745;
$longitude*=0.01745;
$s="select sno from $table[0] where skills regexp \"$skills[0]\"";
for($i=1;$i<count($skills);$i++)
{
$s.=" and skills regexp \"$skills[$i]\"";
}
$s.=" and deposit>=bid";
for($i=0;$i<count($region);$i++)
if(!$region[$i]=="")
{
$s.=" and region regexp \"$region[$i]\"";
}
for($i=0;$i<count($city);$i++)
if(!$city[$i]=="")
{
$s.=" and city regexp \"$city[$i]\"";
}
for($i=0;$i<count($country);$i++)
if(!$country[$i]=="")
{
$s.=" and country regexp \"$country[$i]\"";
}
if(!$latitude=="")
{
$s.=" and acos(sin($latitude) * sin(Lati) + cos($latitude) * cos(Lati) * cos(Longi - ($longitude))) * 6371 <= $distance";
}
$con=mysqli_connect("localhost","root","cutiepie_100",$db);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//print_r($s);
$abc=mysqli_query($con, $s) or die('cannot show tables');
//print_r($s);
while ($row = mysql_fetch_array($abc))
{
// print_r($s);
echo "<tr><td>{$row['sno']}</td></tr>";
}
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.