Jump to content
php.lv forumi

Recommended Posts

Posted

Man te ir uzdevums: nedaudz piestrādāt pie vienas web lapas..

 

Problēma: tabula "jaunumi", parāda tikai pēdējo ierakstu, precīzāk pēdējo/augstāko vērtību no lauka npk (numurs pēc kārtas), ja es nomainu kādam ierakstam 'npk', tas ieraksts automātiski aizvieto iepriekšējo.. kods:

 

 

<?php

$maxnpk = "SELECT MAX(npk) FROM jaunumi";

$maxnpkresult = mysql_query($maxnpk) or die(mysql_error());

while($maxrow = mysql_fetch_array($maxnpkresult)){

$npk = $maxrow['MAX(npk)'];

}

$virtex="select * from jaunumi where npk='$npk'";

$virtexres2=mysql_query($virtex) or die(mysql_error());

while($row = mysql_fetch_array($virtexres2)){

echo "<br />" . $row['date'];

?>

<center class="tab3"><strong> <?php echo $row['virs'] . "</strong></center><br />" . $row['text'] . "<br />";

if ($row['url1'])

{

?>

 

 

mjā.. ceru uz palīdzību..

Posted (edited)

Nesapratu, kas nav skaidrs vai kur vispār ir problēma...

 

P.S. To ko tu esi uzrakstījis, var uzrakstīt šādi:

$row = mysql_fetch_assoc(mysql_query("SELECT * FROM `jaunumi` ORDER BY npk DESC LIMIT 1"));
print_r($row);

 

EDIT: Ak visus gribi... Skaties piemērus šeit.

Edited by marcis
Posted
<?php
$virtex="select * from jaunumi";
$virtexres2=mysql_query($virtex) or die(mysql_error());
while($row = mysql_fetch_array($virtexres2)){
echo "<br />" . $row['date'];
?>
<center class="tab3"><strong> <?php echo $row['virs'] . "</strong></center><br />" . $row['text'] . "<br />";
if ($row['url1'])
{
?>

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.

Loading...
×
×
  • Create New...