Jump to content
php.lv forumi

mysql Update


skrach

Recommended Posts

Sveicināti!

Kāds varētu lūdzu palīdzēt, man radās tāda problēma!

Spiežot uz lapas skaitās nost nauda - 5 crediti , bet es vēlētos lai skaitītos tikai tad kas nospiežu piemēram uz skinu vai kādu citu lietu!

 

skin.php

 

$query = mysql_query("SELECT credits FROM users

WHERE user_id='".$user->user_info[user_id]."'");

$user = new user(Array($user->user_info[user_id]));

$credits = mysql_result($query,0);

$credits = $credits - 5;

$database->database_query("UPDATE users SET credits = '$credits' WHERE user_id='".$user->user_info[user_id]."'");


 

vajadzētu lai nospiežot pogu Jā (value='Jā') noskaitītos nauda, bet ja pogu Nē (value='Nē'), tad credit sum paliktu tada pati! Ka to varētu panākt?

Kods iekšh mana tpl faila:

 

skin.tpl

 

<table cellpadding='0' cellspacing='0' width='100%'>



<h2 style="float: center;">Izvēlies sev piemērotu skinu!</h2>
<br>
<p style="float: left;">

<input style="padding: 3px;" type="image" name="grootte" value="1" src="skin/img/1.jpg" onclick="SetCookie(nameOfCookie, this.value, exp); confirmPrice();">
<input style="padding: 3px;" type="image" name="grootte" value="2" src="skin/img/2.jpg" onclick="SetCookie(nameOfCookie, this.value, exp); confirmPrice();">
<input style="padding: 3px;" type="image" name="grootte" value="3" src="skin/img/3.jpg" onclick="SetCookie(nameOfCookie, this.value, exp); confirmPrice();">



</p>
{literal}
<script type="text/javascript">
<!-- 
function confirmPrice() {
 TB_show('{/literal}{lang_print id=759}{literal}', '#TB_inline?height=100&width=300&inlineId=confirmPrice', '', '../images/trans.gif');

}



//-->
</script>
{/literal}


{* HIDDEN DIV TO DISPLAY CONFIRMATION MESSAGE *}
<div style='display: none;' id='confirmPrice'>
 <div style='margin-top: 10px;'>
   Tiešām vēlaties pirkt šo pakalpojumu?
 </div>
 <br>
 <input type='button' class='button' value='Jā'  onClick='doRefresh();'> 
 <input type='button' class='button' value='Nē' onClick='doRefresh();'>
</div>
 </table>

Edited by skrach
Link to comment
Share on other sites

class liec nevis button bet gan labāk submit!

Uztaisi ar IF(ISSET($_POST['ja'])) notiek tas un tas

IF(ISSET($_POST['ne'])) nenotiek nekas vai aiziet uz linku! :)

 

 

varētu lūdzu apmēram uzrakstīt kā tas kods izskatās?

vnk es esmu iesācējs un ar $_POST vēl neesmu rīkojies

Edited by skrach
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...