Jeg synes godt nok din sidste query er lidt spekulativt hvor du sorterer alle rækkerne i en tabel med en random funktion. har ændret din kode lidt burde kører en infinitisimal smule bedre...forudsat jeg ikke har lavet en fejl et sted kunne jo ikke teste det
.
<?
include("connect.php");
$menu_valgt_menu_punkt = "forside";
include("top.php");
$erhverv=false;
if(isset($_SESSION["loggedin"])){
$query = mysql_query("SELECT erhverv FROM brugere WHERE id = '".$_SESSION["brugerid"]."' LIMIT 1");
list($qerhverv) = mysql_fetch_row($query);
$erhverv=($qerhverv=="1")?true:false;
}
$query = mysql_query("SELECT * FROM nyheder WHERE aktiveret = '1' ORDER BY dato DESC LIMIT 1");
if(mysql_num_rows($query) > 0)
{
$row = mysql_fetch_array($query);
?>
<div style="padding-left: 5px; padding-top: 5px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 579px; height: 20px; background-image: url('gfx/nyhed_top.gif'); background-repeat: no-repeat; vertical-align: top; font-size: 11px; text-align: center; font-weight: bold; color: #000000;">
<?=$row["titel"];?>
</td>
</tr>
<tr>
<td style="width: 579px; height: 138px; background-image: url('gfx/nyhed_content.gif'); background-repeat: repeat-y;">
<div style="padding: 3px 8px 3px 3px; color: #000000; height: 138px; overflow: hidden;">
<?
echo eHTML(nl2br($row["nyhed"]));
?>
</div>
</td>
</tr>
<tr>
<td style="width: 579px; height: 27px; background-image: url('gfx/nyhed_bottom.gif'); background-repeat: no-repeat; vertical-align: middle; font-size: 11px; font-weight: bold; text-align: right; color: #000000;">
<div style="padding-top: 6px; padding-right: 12px;"><a href="nyheder.php" style="color: #000000; text-decoration: none;">Gå til nyhedsarkiv</a></div>
<div style="position: relative; top: -28px; right: 8px; height: 13px; overflow: hidden; text-align: right; font-style: italic; font-weight: normal;"><a href="nyheder.php?id=<?=$row["id"];?>" style="font-style: normal;">Læs mere...</a> <?=date("m-d-Y H:i:s",$row["dato"]);?></div>
</td>
</tr>
</table>
</div>
<?
}
?>
<div style="padding-left: 5px; padding-top: 5px;">
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<tr>
<?
$tilbud1 = 0;
$tilbud2 = 0;
$query = mysql_query("SELECT * FROM produkter WHERE aktiveret = '1' ORDER BY oprettelses_dato DESC LIMIT 2");
$varenummer=array();
if(mysql_num_rows($query) > 0)
{
$first=true;
while($row = mysql_fetch_array($query)){
$varenummer[]="varer_nummer!='".$row["varer_nummer"]."'";
if($erhverv){
$pris = RoundPrice($row["pris"] * (($row["fortjeneste"] / 100) + 1));
$tilbudspris = RoundPrice($row["tilbudspris"]);
}else{
$pris = RoundPrice(($row["pris"] * (($row["fortjeneste"] / 100) + 1)*1.25));
$tilbudspris = RoundPrice($row["tilbudspris"] * 1.25);
}
$image = $row["billede"];
if($image == "")
$image = "noimage.gif";
?>
<td style="width: 283px;" align="left">
<table cellpadding="0" cellspacing="0" align="left">
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 281px; height: 16px; background-image: url('gfx/vare_top.gif'); background-repeat: no-repeat; vertical-align: top; font-size: 11px; text-align: center; font-weight: bold; color: black;">
<?=$row["navn"];?>
</td>
</tr>
<tr>
<td style="width: 281px; height: 23px; background-image: url('gfx/vare_content.gif'); background-repeat: repeat-y;">
<div style="padding: 3px; color: #000000;">
<table>
<tr>
<td><a href="produkter.php?proid=<?=$row["varer_nummer"];?>"><img style="border: 1px solid #CCCCCC; height: 75px;" src="images/<?=$image;?>" alt="<?=$row["navn"];?>" /></a></td>
<td>
<div style="overflow: hidden;">
<span style="font-weight: bold; letter-spacing: normal; color: black; font-size: 12px;" class="cpproddesc"><?=$row["beskrivelse"];?></span><br /><br />
<?
if($tilbudspris == "0"){
?>
<span>Pris:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;">DKK <?=RoundPriceForOutput($pris);?></span><br />
<?
} else {
$sparer = RoundPrice($pris - RoundPrice($tilbudspris));
?>
<span>Pris:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;">DKK <?=RoundPriceForOutput(RoundPrice($tilbudspris));?></span><br />
<span>Før Pris:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;"><s>DKK <?=RoundPriceForOutput($pris);?></s></span><br />
<span>Du sparer:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;">DKK <?=RoundPriceForOutput($sparer);?></span><br />
<?
}
?>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td style="width: 281px; height: 21px; background-image: url('gfx/vare_bottom.gif'); background-repeat: no-repeat; vertical-align: middle; font-size: 11px; font-weight: bold; text-align: right; color: #FFFFFF;">
<a href="produkter.php?proid=<?=$row["varer_nummer"];?>" style="color: black; text-decoration: none;">Se detaljer</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<?
if($first){
echo "<td> </td>";
$first=false;
}
}
}
?>
</tr>
</table>
</div>
<div style="padding-left: 5px; padding-top: 5px;">
<table cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
<tr>
<?
$query = mysql_query("SELECT * FROM produkter WHERE tilbudspris >0 ".((count($varenummer)>0)?"AND ".implode(" AND ",$varenummer):"")." ORDER BY RAND() DESC LIMI 2"); //ORDER BY oprettelses_dato
if(mysql_num_rows($query) > 0){
$first = true;
while($row = mysql_fetch_array($query)){
if($erhverv){
$pris = RoundPrice($row["pris"] * (($row["fortjeneste"] / 100) + 1));
$tilbudspris = RoundPrice($row["tilbudspris"]);
}else{
$pris = RoundPrice(($row["pris"] * (($row["fortjeneste"] / 100) + 1)*1.25));
$tilbudspris = RoundPrice($row["tilbudspris"] * 1.25);
}
$image = $row["billede"];
if($image == "")
$image = "noimage.gif";
?>
<td style="width: 283px;" align="left">
<table cellpadding="0" cellspacing="0" align="left">
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 281px; height: 16px; background-image: url('gfx/vare_top.gif'); background-repeat: no-repeat; vertical-align: top; font-size: 11px; text-align: center; font-weight: bold; color: black;">
<?=$row["navn"];?>
</td>
</tr>
<tr>
<td style="width: 281px; height: 23px; background-image: url('gfx/vare_content.gif'); background-repeat: repeat-y;">
<div style="padding: 3px; color: #000000;">
<table>
<tr>
<td><a href="produkter.php?proid=<?=$row["varer_nummer"];?>"><img style="border: 1px solid #CCCCCC; height: 75px;" src="images/<?=$image;?>" alt="<?=$row["navn"];?>" /></a></td>
<td>
<div style="overflow: hidden;">
<span style="font-weight: bold; letter-spacing: normal; color: black; font-size: 12px;" class="cpproddesc"><?=$row["beskrivelse"];?></span><br /><br />
<?
if($tilbudspris == "0"){
?>
<span>Pris:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;">DKK <?=RoundPriceForOutput($pris);?></span><br />
<?
} else {
$sparer = RoundPrice($pris - RoundPrice($tilbudspris));
?>
<span>Pris:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;">DKK <?=RoundPriceForOutput(RoundPrice($tilbudspris));?></span><br />
<span>Før Pris:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;"><s>DKK <?=RoundPriceForOutput($pris);?></s></span><br />
<span>Du sparer:</span> <span class="CPprodLPriceV" style="font-weight: bold; font-family: verdana, arial; color: black;">DKK <?=RoundPriceForOutput($sparer);?></span><br />
<?
}
?>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td style="width: 281px; height: 21px; background-image: url('gfx/vare_bottom.gif'); background-repeat: no-repeat; vertical-align: middle; font-size: 11px; font-weight: bold; text-align: right; color: #FFFFFF;">
<a href="produkter.php?proid=<?=$row["varer_nummer"];?>" style="color: black; text-decoration: none;">Se detaljer</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<?
if($first){
echo "<td> </td>";
$first=false;
}
}
}
?>
<tr>
<td colspan="2">
<br>
<span class="bold"><div style="overflow: hidden;"><a href="tilbud.php">Klik her for at se alle tilbudene!</a></div></span>
</td>
</tr>
</tr>
</table>
</div>
<?
include("bund.php");
?>
PS. hvis du poster kode i fremtiden kan du så ikke gøre det i code tags ellers fjernes indents.
PPS. håber virkelig at din kode har indents
PPPS. De er noget der hedder booleans, jeg synes du skal bruge dem når en ting kun kan være enten eller, f.eks kan en ting kun være first eller ikke first.
PPPPS. Men eftersom at alle andre dele af den side er langsomme vil jeg mene at det ikke er den viste kode der er dit problem
PPPPPS. Og at åbne nye browser vinduer/faner burde forbydes.
Indlæg senest redigeret d. 25.09.2007 17:56 af Bruger #5620