BaLTais Posted October 25, 2011 Report Share Posted October 25, 2011 Sveiki. Problēmas kods.: . . . do { printf ("<table align = 'center' class ='post'> <tr> <td class='post_title'> <p class='post_name'>< a href='view_post.php?id=%s'>%s</a></p> <p class='post_adds'>Pievienots: %s</p> <p class='post_adds'>Autors: %s</p></td></tr> <tr> <td>%s <br>Skatījumi: %s</td> </tr> </table><br></br>",$myrow["id"],$myrow["title"],$myrow["date"],$myrow["author"],$myrow["description"],$myrow["view"]); } while ($myrow = mysql_fetch_array($result)); . . . Problēma ir šājā rindiņā : <p class='post_name'>< a href='view_post.php?id=%s'>%s</a></p> Visus citus s% elementus izvada korekti, bet šī rindiņa izdod : a href=view_post.php?id=5 [+ nolasītais ieraksts no db] Sanāk, ka nolasa no db, bet linku gan nepiesaista.. Kādēļ tā? Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted October 25, 2011 Report Share Posted October 25, 2011 Kapēc integeru definē ar %s? Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 25, 2011 Report Share Posted October 25, 2011 Pamēģini ar %d, bet ja nopietni... beidz muļķoties. <span class="content"> <?php echo $content; ?> </span> Quote Link to comment Share on other sites More sharing options...
BaLTais Posted October 25, 2011 Author Report Share Posted October 25, 2011 Domā pārveidot visu, lai izvada ar echo? Quote Link to comment Share on other sites More sharing options...
briedis Posted October 25, 2011 Report Share Posted October 25, 2011 (edited) while($row = mysql_fetch_array($result)){ ?> <table align = 'center' class ='post'> <tr> <td class='post_title'> <p class='post_name'><a href='view_post.php?id=<?=$row['...'];?>'><?=$row['...'];?></a></p> <p class='post_adds'>Pievienots: <?=$row['...'];?></p> <p class='post_adds'>Autors: <?=$row['...'];?></p> </td> </tr> <tr> <td>%s <br>Skatījumi: <?=$row['...'];?></td> </tr> </table> <br/><br/> <? } Edited October 25, 2011 by briedis Quote Link to comment Share on other sites More sharing options...
xfr33 Posted October 25, 2011 Report Share Posted October 25, 2011 Man ir jautājums par līdzīgu tēmu: ja ar printf es varu izdrukāt masīvu, kā es varu tur pārveidot kko, lai varu piem ar echo izdrukāt no masīva vienas kolonnas ierakstu? Quote Link to comment Share on other sites More sharing options...
briedis Posted October 25, 2011 Report Share Posted October 25, 2011 Nesaprotu? printf tāpat kā ar echo nevar izdrukāt masīvu. Var drukāt pa vienam elementam. Quote Link to comment Share on other sites More sharing options...
xfr33 Posted October 25, 2011 Report Share Posted October 25, 2011 Nesaprotu? printf tāpat kā ar echo nevar izdrukāt masīvu. Var drukāt pa vienam elementam. ja es uzrakstu teiksim printf($blabla) un man izdrukā masīvu: a[1] -> "Ābols", a[2] -> "Banāns" utt kā es varu dabūt katru elementu atsevišķi un izdrukāt? Quote Link to comment Share on other sites More sharing options...
briedis Posted October 25, 2011 Report Share Posted October 25, 2011 Pamācies pamatus par masīviem: http://www.tizag.com/phpT/arrays.php (tur ir arī citi labi tutoriāļi, iesaku iziet cauri.) Quote Link to comment Share on other sites More sharing options...
xfr33 Posted October 25, 2011 Report Share Posted October 25, 2011 (edited) Pamācies pamatus par masīviem: http://www.tizag.com/phpT/arrays.php (tur ir arī citi labi tutoriāļi, iesaku iziet cauri.) Es zinu pamatus par masīviem. Ok, anyway, ja nav atbildes, tad neko. Edited October 25, 2011 by xfr33 Quote Link to comment Share on other sites More sharing options...
viena tante Posted October 25, 2011 Report Share Posted October 25, 2011 Es zinu pamatus par masīviem. Ok, anyway, ja nav atbildes, tad neko. ja Tu zinātu pamatus tad Tu zinātu, ka ir kaut vai tāds foreach. Quote Link to comment Share on other sites More sharing options...
briedis Posted October 25, 2011 Report Share Posted October 25, 2011 Sāksim jau ar to, printf($masivs) izdrukās Array. Gadījumā nejauc funkciju ar print_r($masivs)? Tiešām, ja zinātu pamatus, tad apskatot to rezultātu, ko izdrukā print_r, nevajadzētu būt problēmām spēt piekļūt attiecīgajām vērtībām pēc to indeksiem, kas ir viegli nolasāmi. http://codepad.viper-7.com/z2Dhgr Quote Link to comment Share on other sites More sharing options...
xfr33 Posted October 25, 2011 Report Share Posted October 25, 2011 Sāksim jau ar to, printf($masivs) izdrukās Array. Gadījumā nejauc funkciju ar print_r($masivs)? Tiešām, ja zinātu pamatus, tad apskatot to rezultātu, ko izdrukā print_r, nevajadzētu būt problēmām spēt piekļūt attiecīgajām vērtībām pēc to indeksiem, kas ir viegli nolasāmi. http://codepad.viper-7.com/z2Dhgr Ok, paldies par pūlēm izskaidrot, bet lai paliek. Quote Link to comment Share on other sites More sharing options...
briedis Posted October 25, 2011 Report Share Posted October 25, 2011 xfr33, neesi tik stūrgalvīgs. Pēdējā dotajā linkā ir ļoti vienkāršs piemērs, turpat vari pamainīt vērtības un skatīties, kā kas mainās. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted October 25, 2011 Report Share Posted October 25, 2011 Domāju, ka vēlies panākt: printf("%s", $foo['x']); ...vai: foreach ($foo as $x) { printf("%s", $x]); } Bet jebkura gadījumā, nevajag jums tos printf, sprintf uc. f'us...: <?php foreach ($foo as $x): ?> <span class="content"><?php echo $x['content']; ?></span> <?php endforeach; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.