EDIT : Using mysql_connect
in PHP 7
. Solved .
I've try to make a table with the last entry in my Database, so i've try to get my last 5 data and repeat it in a table.
This is the structure of my Database:
CREATE TABLE `submitph` (
`id` int(11) NOT NULL,
`phrase` text NOT NULL,
`mode` varchar(255) NOT NULL,
`enable` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
And my php code
<tbody>
<?php
mysql_connect("localhost", "root", "root");
mysql_select_db("jnj");
$retour = mysql_query('SELECT * FROM submitph ORDER BY id DESC LIMIT 0,5');
while ($donnees = mysql_fetch_array($retour))
{
?>
<tr>
<td>
<?php echo stripslashes($donnees['id']); ?>
</td>
<td>
<?php
$phrase = nl2br(stripslashes($donnees['phrase']));
echo $phrase;
?>
</td>
<td>
<a href="">Approuver</a> / <a href="">Refuser</a>
</td>
</tr>
<?php
} ?>
</tbody>
But i didn't have any data in my table, i didn't have any php error, didn't understand why. Did i miss something ?
EDIT 1 (All my table) :
<table class="table table-hover">
<thead class="">
<th>
ID
</th>
<th>
Phrase
</th>
<th>
Status
</th>
</thead>
<tbody>
<?php
mysql_connect("localhost", "root", "root");
mysql_select_db("jnj");
$retour = mysql_query('SELECT * FROM submitph ORDER BY id DESC LIMIT 0,5');
while ($donnees = mysql_fetch_array($retour))
{
?>
<tr>
<td>
<?php echo stripslashes($donnees['id']); ?>
</td>
<td>
<?php
$phrase = nl2br(stripslashes($donnees['phrase']));
echo $phrase;
?>
</td>
<td>
<a href="">Approuver</a> / <a href="">Refuser</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
EDIT 2 : SQL Data
INSERT INTO `submitph` (`id`, `phrase`, `mode`, `enable`) VALUES
(3, 'Test1', 'Hard', 0),
(5, 'Test2', 'Soft', 0),
(6, 'Test3', 'Hard', 0);
您没有将$ connection变量传递给mysql_query();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.