mastercjb Posted June 2, 2009 Share Posted June 2, 2009 I have a code for selling a house in my game. I'm trying to figure out how to make it to where, if someone clicks Sell Your House then it will ask you "Are You Sure You Wish To Sell Your House?". The only way I can think to do it would be with javascript, but I cant seem to get java into this code... Can someone please help. Heres my page script. <?php include 'header.php'; if($_GET['buy'] != ''){ $result = mysql_query("SELECT * FROM `houses` WHERE `id`='".$_GET['buy']."'"); $worked = mysql_fetch_array($result); $cost = $worked['cost']; if($user_class->house != 0){ $result2 = mysql_query("SELECT * FROM `houses` WHERE `id`='".$user_class->house."'"); $worked2 = mysql_fetch_array($result2); $cost = $cost - ($worked2['cost'] * .75); echo Message('You have sold your house for 75% of what it was worth ($'.$cost."). That amount will go towards the purchase of the new house."); } if($cost > $user_class->money) { echo Message("You don't have enough money to buy that house."); } if($cost <= $user_class->money && $worked['name'] != "") { $newmoney = $user_class->money - $cost; $result = mysql_query("UPDATE `grpgusers` SET `house` = '".$_GET['buy']."', `money` = '".$newmoney."' WHERE `id`='".$_SESSION['id']."'"); echo Message("You have purchased and moved into ".$worked['name']."."); $user_class = new User($_SESSION['id']); } if ($worked['name'] == ""){ echo Message("That's not a real house."); } } ?> <tr><td class="contenthead">Move House</td></tr> <? if($user_class->house > 0){ echo "<tr><td class='contentcontent' align='center'><a href='house.php?action=sell'>Sell Your House</a></td></tr>"; } ?> <tr><td class="contentcontent"> <table width='100%'> <tr> <td width='45%'><b>Type</b></td> <td width='15%'><b>Awake</b></td> <td width='20%'><b>Cost</b></td> <td width='20%'><b>Move</b></td> </tr> <?php $result = mysql_query("SELECT * FROM `houses` ORDER BY `id` ASC"); while($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr><td width='45%'>".$line['name']."</td><td>".$line['awake']."</td><td>\$".$line['cost']."</td><td>"; if($line['id'] > $user_class->house){ echo "<a href='house.php?buy=".$line['id']."'>Move In</a>"; } echo "</td></tr>"; } ?> </table> </td></tr> <?php include 'footer.php'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/160580-solved-php-confirmation/ Share on other sites More sharing options...
BK87 Posted June 2, 2009 Share Posted June 2, 2009 try... <? if($user_class->house > 0){ echo "<tr><td class='contentcontent' align='center'><a href='house.php?action=sell' onclick=\"return confirm('Do you want to sell your home?');\" >Sell Your House</a></td></tr>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/160580-solved-php-confirmation/#findComment-847516 Share on other sites More sharing options...
mastercjb Posted June 2, 2009 Author Share Posted June 2, 2009 Solved. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/160580-solved-php-confirmation/#findComment-847529 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.