amis00 Posted January 25, 2009 Report Share Posted January 25, 2009 Esmu izveidojis šādu kodu. Gribētu lai piemēram uzpiežot uz Australia attēlotos kā id_race 1 utt. <?php $db = mysql_connect("localhost", "user", "pasword"); mysql_select_db("f1c",$db); $result = mysql_query("SELECT * FROM race_table WHERE id_race IN (1,2,3) ORDER BY id_race, r_place ",$db); if ($myrow = mysql_fetch_array($result)) { echo "<center><table></center>"; echo "<tr><td>Australia</td><td>Malaisya</td><td>China</td></tr>"; echo "</table>"; echo "<center><table cellpadding=1 cellspacing=1 bordercolor=black bgcolor=white border=1>\n"; echo "<tr> <center><td><center><b>Trase</b></center></td> <td><center><b>Braucejs</b></center></td> <td><center><b>R<br>Vieta</b></center></td> <td><center><b>Punkti</b></center></td> <td><center><b>Komanda</b></center></td> </tr> \n"; do { printf("<tr> <td><center>%s</center></td> <td><center>%s</center></td> <td><center>%s</center></td> <td><center>%s</center></td> <td><center><img src='/f1c/images/flag/car/". $myrow["driver_team"] .".png'></center></td> </tr> \n", $myrow["track"], $myrow["driver"], $myrow["r_place"], $myrow["points"], $myrow["driver_team"]); } while ($myrow = mysql_fetch_array($result)); echo "</center></table>\n"; } else { echo "Sorry, no records were found!"; } ?> Link to comment Share on other sites More sharing options...
bubu Posted January 25, 2009 Report Share Posted January 25, 2009 Nesapratu ko tu gribi panākt. Šito? <a href="?id_race=1">Australia</a> Link to comment Share on other sites More sharing options...
amis00 Posted January 25, 2009 Author Report Share Posted January 25, 2009 (edited) http://www.jtsk.lv/f1c/kop.php Man izkatās šādi, bet es gribu lai uzpiežot uz austrālija attēlotu tikai australia (tas ir ID=1) utt. Edited January 25, 2009 by amis00 Link to comment Share on other sites More sharing options...
bubu Posted January 25, 2009 Report Share Posted January 25, 2009 Padod vajadzīgo id GET parametrā (tieši tā kā es kodā uzrakstīju). Tik protams to ID velc ārā no DB, nevis statiski kodā ieraksti. Un tad, kad vajadzīgs izselektēt konkrētās valsts ierakstus, tad izmanto šo GET parametra vērtību savā SQL kverijā: $id = isset($_GET["id"]) ? intval($_GET["id"]) : $defaultais_id; SELECT ... FROM ... WHERE id = $id Link to comment Share on other sites More sharing options...
amis00 Posted January 25, 2009 Author Report Share Posted January 25, 2009 (edited) Paldies, kaut kas izdevās! Tomēr rodas nākamais jautājums - Ko īsti tajā kodā nozīmē: $defaultais_id Vēlos tā lai piemēram ja nav uzspiest neviens links tad rāda id 1, vai arī kaut ko citu ko esmu norādījis, savādāk tur ir tukša tabula un diezgan nepilnīgi atainojās. Edited January 25, 2009 by amis00 Link to comment Share on other sites More sharing options...
bubu Posted January 25, 2009 Report Share Posted January 25, 2009 Šausmīgs teksts. Tev skolā komatus nemāca likt? Tas defaultais_id to arī nozīmē, ko prasi. T.i. ko rādīt, ja nav GET parametrā tas id ielikts. Link to comment Share on other sites More sharing options...
amis00 Posted January 25, 2009 Author Report Share Posted January 25, 2009 (edited) Bet, kā viņš zinās, ka viņam ir jārāda tas un tas, ja iepriekšs nekur, tas nav norādīts. Tā $defaultais_id vietā mēģināju likt skaitļus, bet nekas nemainījās. Edited January 25, 2009 by amis00 Link to comment Share on other sites More sharing options...
Recommended Posts