Jump to content
soimuletzu1

Extragere din db (php)

Recommended Posts

Posted

Salutare, am si eu o problema la un mic script .... incerc sa extrag din baza de date ultimul id de la o lista de siteuri (ii la un topsites) da problema ii ca imi afiseaza toate idurile ...

Scriptul e urmatorul:


<?php
//conexiune
$afisare=mysql_query("SELECT * FROM ts_sites");
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="51%" scope="col">Idul siteului</td>
</tr>
<?php
while ($row=mysql_fetch_row($afisare)) {
//variabilele definite
$id = $row[0];
?>
<tr>
<td><? echo "$id"; ?></td>
</tr>
<?php } ?>
</table>

Cum ar trebui sa folosesc functia de extragere incat sa selecteze doar ultimul id?

Rog sa raspunda cei care cunosc .. si multumesc frumos!

Posted

<?php

//conexiune

$afisare=mysql_query("SELECT * FROM ts_sites order by id desc limit 1");

?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>

<td width="51%" scope="col">Idul siteului</td>

</tr>

<?php

while ($row=mysql_fetch_row($afisare)) {

//variabilele definite

$id = $row['id'];

?>

<tr>

<td><? echo "$id"; ?></td>

</tr>

<?php } ?>

</table>

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...