Jump to content
jordi72

[PHP & MySQLi] Code not working

Recommended Posts

Hello, I'm a bit new coding PHP, I'm trying to make a page to see the server status (not real servers) I just got a DB with this structure: https://prnt.sc/huch18

And I just want to set flags like a check or X depending on the Disponibility of the server, obtained from the DB using this code:

<html>
<head>
<title>testing php </title>
</head>
<body>
<?php
$link = @mysqli_connect(
'localhost',
'root',
'12345',
'admin');
if(!$link){
	echo '<p>Error al conectar con la base de datos: '
	. mysqli_connect_error();
	echo '</p>';
	exit;
}

$servers = ("SELECT * FROM servers");
$query = mysqli_query($link, $servers) or trigger_error($link->error."[$servers]");

echo "<table>";
while($row = mysqli_fetch_assoc($query)){
	$serverName = $row['nom'];
	$serverDispo = $row['disponibilitat'];
	$serverPopu = $row['poblacio'];
	$serverQue = $row['cua']; 
	echo "<tr><td>".$serverName."</td><td>".$serverDispo."</td><td>".$serverPopu."</td><td>".$serverQue."</td></tr>";
}
mysqli_free_result($query);
echo "</table>";
}
?>
</body>
</html>

I know I'm not setting the flags, I just want to get the table with results. And this is the result: https://prnt.sc/huckqk

Maybe I'm making a noob mistake but I need help ;(

Share this post


Link to post
Share on other sites
1 hour ago, jordi72 said:

Ok, guys, I just found the problem, the last } xD just deleted and working fine, now just need a cool CSS.

hehe :D so this can be considered closed then?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

×