Jump to content
php.lv forumi

IZVADE nesanāk kā paredzēts


tk1

Recommended Posts

openside("topGMGsites ieskats");
// Connecting, selecting database
$link = mysql_connect('e-dreams.lv', 'gadmin', '')
  or die('Could not connect: ' . mysql_error());
mysql_select_db('gmg') or die('Could not select database');

// Performing SQL query
$query = 'SELECT `title` FROM ats_sites ORDER BY join_date DESC LIMIT 3';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
foreach ($line as $izvade) {
$query2 = 'SELECT `url` FROM ats_sites ORDER BY join_date DESC LIMIT 3';
$result2 = mysql_query($query2) or die('Query failed: ' . mysql_error());
while ($line2 = mysql_fetch_array($result2, MYSQL_ASSOC)) {
  foreach ($line2 as $linkk) {

	}
  }
echo "<br/> <a href='$linkk'>$izvade</a>\n";
}

}



// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);

closeside();

 

Doma ir izvadīt 3 ierakstus linka veidā! Bet zinakums :

http://img158.imageshack.us/img158/4659/lolto4.jpg

Link to comment
Share on other sites

Ak, dies...

 

nezinu gan kur tu manuāli esi redzējis tādu piemēru, tu pašlaik katram ierakstam vēl velc arā datus no tās pašas tabulas. Un piedevām diezgan nesekmīgi...

Reali tev pietiek ar šo:

$query = 'SELECT title, url FROM ats_sites ORDER BY join_date DESC LIMIT 3';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_assoc($result)) {
echo '<br/> <a href="'.$row['url'].'">'.$row['title'].'</a>';
}

Link to comment
Share on other sites

×
×
  • Create New...