0
A few days ago, I’ve been trying to get my comic book search to be presented internally to a bordered table. However, although the server does not return any error, no results are shown. I have already made several changes in the syntax regarding the positioning of the Tables tags, putting it internally to WHILE but so far I have not had any success. It follows below the last way I tried:
<html>
<head>
<title>Extraindo dados do BD</title>
</head>
<body>
<?php
mysql_connect("localhost","DB1","XXXX") or die(mysql_error());
mysql_select_db("database1") or die(mysql_error());
$selecaodedados= "SELECT * FROM meubancodedados";
echo "<table style="1px">";
echo "<thead> <tr> <th colspan='6'>Lista 1 </th></tr>"
."</tread>";
echo "<tr>"
."<th> A dado </th> <th> B dado </th> <th> C dado </th>"
." <th>D dado </th> <th> E dado </th> <th> F total </th>"
."</tr>";
echo "</thead>";
echo " <tbody>";
while($linha= mysql_fetch_array($selecaodedados)){
echo "<tr>"
."<td>".$linha['A']. "</td><td> ". $linha['B']"
. " </td><td> ".$linha['C']. "</td><td> ". $linha['D']"
. "</td><td> ". $linha['E']."</td><td> ".$linha['F']. "</td><br/>"
."</tr>";
}
echo "</tbody>";
echo "</table>";
mysql_close();
?>
</body>
Grateful brother. In fact it became much more organized than just calling the data with the mysql_fetch_array. However there is no way to put the information in the head of the table or even stylize it by placing edge or similar? The website edition took away the part where I reported that I’m a beginner in programming, so I forgive you for any nonsense you’re saying.
– Lucas Menezes
@Lucasmenezes, it is still possible to do whatever you want with the table by CSS, just put the CSS code normally changing the table, to put the
head
also, you can use aecho
with the table head, or put out the php tag.– Brumazzi DB
I had tried, without success. The result I had was something strange. Both with the head inside php and outside, what the server returned to me was 39 repetitions of for(=0; written in line, and below the information from Head. So I asked if it was possible to style the table generated by the search. But I realized where the error of my syntax was. The "for" you recommended I use is missing a pair of keys circling it.
– Lucas Menezes
Just two more questions, brother. In case you don’t want to show all the BD columns, how would you recommend coding? And as the other friend reported that Mysql is falling into disuse, what you recommend as a good alternative?
– Lucas Menezes
mysql is not in disuse, the function
mysql
is becoming obsolete in php and are migrating tomysqli
. In the case of fields, the best method would be not to select the fields in SQL, or to use themysql_fetch_assoc
and theforeach
and a condition for the fields you do not wish to show– Brumazzi DB
Although the warning of "avoid comments as Thanks" I find very clumsy and of a very great coldness, leave without thanks for the help. Grateful brother.
– Lucas Menezes