tk1 Posted February 3, 2008 Report Share Posted February 3, 2008 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 More sharing options...
bubu Posted February 3, 2008 Report Share Posted February 3, 2008 Kas tev tie par jocīgiem tukšiem cikliem? foreach ($line2 as $linkk) { } un while ($line2 = mysql_fetch_array($result2, MYSQL_ASSOC)) { foreach ($line2 as $linkk) { } } Link to comment Share on other sites More sharing options...
tk1 Posted February 3, 2008 Author Report Share Posted February 3, 2008 No mysql esmu gandrīz 0, centos no parauga kas dots php.net sadaļā mysql uztaisīt, bet redz ka nesanāk Link to comment Share on other sites More sharing options...
Lynx Posted February 3, 2008 Report Share Posted February 3, 2008 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 More sharing options...
Recommended Posts