Gochix Posted February 4, 2014 Report Share Posted February 4, 2014 Sveiki, man ir vajadzīgs kaut kas līdzīgs ipoints shopam,...ir piemēram db fields..atteloju viņu šādi.. $data1 = mysql_query("SELECT points FROM ibf_members WHERE id = $member_id") or die(mysql_error()); while($info = mysql_fetch_array( $data1 )) { Print "<td><b><font color=red>Chaos Points:</b></font><b><font color=green> ".$info['points']. "</b></font></td> "; } tad nu gribu uztaisīt tādu kā tabuliņu, kur ir piemēram kaut kāds item = nosaukums, un takā ieķeksēt var viņā iekšā un nospiest pogu pirkt. un pie pirkt pogas aprēķināt ja ir pietiekami daudz chaos points tad atnemt chaos points piemēram 100 updeitojot info @db.. var kāds vismaz kādu piemēru parādīt kā kko tamlīdzīgu var uztaisīt?? Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 4, 2014 Report Share Posted February 4, 2014 var kāds vismaz kādu piemēru parādīt kā kko tamlīdzīgu var uztaisīt?? Kāds ir plānotais budžets tam, kurš tev to uztaisīs? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted February 4, 2014 Report Share Posted February 4, 2014 if ( $chaos_points > $itema_cena ) { iedod_userim_itemu(); mysql_query("UPDATE `ibf_members` SET `points` = `points` - $itema_cena WHERE `id` = $member_id"); echo 'Zajebis!'; } Quote Link to comment Share on other sites More sharing options...
Gochix Posted February 4, 2014 Author Report Share Posted February 4, 2014 <?php if(isset($_POST['buy'])){ if(isset($_POST['id'])){ if ( $chaos_points > $itema_cena ) { iedod_userim_itemu();// šo nevajag te pats tikšu galā.. mysql_query("UPDATE `ibf_members` SET `points` = `points` - $itema_cena WHERE `id` = $member_id"); echo "<center><b><font color=green>Pirkums veiksmīgs!</font></b></center>"; }else{ echo "<center><b><font color=red>Nepietiekami Chaos pointi!</font></b></center>"; } } ?> tik kā tur varēja noteikt tos $chaos_points = mysql_query("SELECT `points` FROM `ibf_members` WHERE `id` = $member_id"); kkā tā? Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 4, 2014 Report Share Posted February 4, 2014 Quote Link to comment Share on other sites More sharing options...
Gochix Posted February 4, 2014 Author Report Share Posted February 4, 2014 (edited) kopējais php kods, itkā viss iet izņemot vienu rindiņu, jo tur nedrīkst būt vienāds vai lielāks.. kā appiet?izskatās jau drausmīgi zinu.. <?php include ("config.php"); if(isset($_POST['buy'])){ if(isset($_POST['item1'])){ $chaos_points = mysql_query("SELECT points FROM ibf_members WHERE id = $member_id") or die(mysql_error()); while($info = mysql_fetch_array( $chaos_points )) if ( $info['points'] => 200 ) { // šeit neļauj => kopā būt.. // Daram kaut ko ar item1 echo "<center><b><font color=green>Pirkums veiksmīgs!".$info['points']. "</font></b></center>"; }else{ echo "<center><b><font color=red>Nepietiekami Chaos pointi!</font></b></center>"; } } } ?> Edited February 4, 2014 by Gochix Quote Link to comment Share on other sites More sharing options...
Kavacky Posted February 4, 2014 Report Share Posted February 4, 2014 ">=" nevis "=>". Quote Link to comment Share on other sites More sharing options...
Gochix Posted February 4, 2014 Author Report Share Posted February 4, 2014 ">=" nevis "=>". Paldies :) Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 4, 2014 Report Share Posted February 4, 2014 Lūdzu raksti tā, lai arī citiem vēlāk ir iespējams ātri orientēties tavā kodā: <?php require_once "config.php"; if(isset($_POST['buy'], $_POST['item1'])) { $chaos_points = mysql_query("SELECT points FROM ibf_members WHERE id = {$member_id}") or die(mysql_error()); while($info = mysql_fetch_array($chaos_points)) { $op1 = "<center><b><font color=green>Pirkums veiksmīgs! {$info['points']}</font></b></center>"; $op2 = "<center><b><font color=red>Nepietiekami Chaos pointi!</font></b></center>"; print($info['points'] >= 200 ? $op1 : $op2); } } un, ja protams tas ir iespējams, izmanto vismaz mysqli->prepare opciju ... Quote Link to comment Share on other sites More sharing options...
jurchiks Posted February 4, 2014 Report Share Posted February 4, 2014 (edited) if (isset($_POST['buy'], $_POST['item1'])) Nafig tās stulbās atstarpes iekš visām iekavām? Mākslīga koda uzpūšana, lai izskatītos, ka vairāk? Closing PHP tags arī nav vajadzīgs un vispār iesaka to neizmantot, ja pēc tā nekas neseko. require/include nav funkcijas, tām iekavas nevajag. Edited February 4, 2014 by jurchiks Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 4, 2014 Report Share Posted February 4, 2014 jurchik, tas kā katram vieglāk lasīt, man tā ir vieglāk, tāpēc arī lieku atstarpes, bet jā, rediģēju anyways. Par require_once piekrītu ( paldies ), bet par closing tag gan nekad laikam nesapratīšu. Zinu, ka standarts paredz šamo nelietot, bet laikam esmu pa vecu, lai piespeistu sevi nenoslēgt scriptu ar aizverošo tagu. Quote Link to comment Share on other sites More sharing options...
Džei Posted February 4, 2014 Report Share Posted February 4, 2014 es arī lieku atstarpes, tas padara kodu tīrāku un vieglāk nolasāmu. closing tags gan nav jāliek Quote Link to comment Share on other sites More sharing options...
jurchiks Posted February 4, 2014 Report Share Posted February 4, 2014 (edited) $info['points'] >= 200 ? print $op1 : print $op2;Stipras aizdomas, ka šis nestrādās.Būtu jābūt: echo (($info['points'] >= 200) ? $op1 : $op2); No closing tag - lai nekas pēc tā netiktu izvadīts, piemēram, kaut kāds lieks whitespace. Edited February 4, 2014 by jurchiks Quote Link to comment Share on other sites More sharing options...
aaxc Posted February 5, 2014 Report Share Posted February 5, 2014 $info['points'] >= 200 ? print $op1 : print $op2; Stipras aizdomas, ka šis nestrādās. PHP Fiddle Quote Link to comment Share on other sites More sharing options...
jurchiks Posted February 5, 2014 Report Share Posted February 5, 2014 Whatever, still pointless to repeat the same command twice. 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.