joca91 Posted July 28, 2011 Share Posted July 28, 2011 Hello! i want help with php snippet for function like this: Users can buy athletes with points wich they have get when they registrated. I also want it if the user don`t have points to buy one athlete the "buy" button would be disabled. Please help me with php code how i can fix it! This is a screenshot how i want the function look like: http://img9.imageshack.us/img9/840/webmanagergame.png Quote Link to comment https://forums.phpfreaks.com/topic/243125-help-with-online-based-manager-phpmysql/ Share on other sites More sharing options...
Maq Posted July 28, 2011 Share Posted July 28, 2011 Post the relevant code. Quote Link to comment https://forums.phpfreaks.com/topic/243125-help-with-online-based-manager-phpmysql/#findComment-1248743 Share on other sites More sharing options...
xyph Posted July 28, 2011 Share Posted July 28, 2011 Do you want us to code for you, or do you actually plan on implementing an example into your existing code? This is a VERY VERY simple logic problem, and if you're able to code a whole purchasing system, this shouldn't be a problem. Don't give me BS like "I'm trying to learn." A complex script is a terrible spot to start, especially if you cant grasp if/then/comparison operators. When you loop out your items to display them, add a simple check if( $users_points < $item_cost ) { echo '<button type="button" disabled="disabled">Not Enough Money</button>'; } else { echo '<input type="submit" name="buy" value="Buy me">'; } Quote Link to comment https://forums.phpfreaks.com/topic/243125-help-with-online-based-manager-phpmysql/#findComment-1248750 Share on other sites More sharing options...
joca91 Posted July 28, 2011 Author Share Posted July 28, 2011 This is how far i have come with the code please help me out, i also think im doing wrong! and the code is not finished! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <p><a href="">Logga UT</a> - <a href="byggalaget.php">Köp cyklister</a> - <a href="kalender.php">Kalender</a>- <a href="profil.php?anv=$anv">Min Profil</a></p> <h1>Här bygger du ditt lag!</h1> <?php session_start(); ?> <?php # anslutning till databas!´ $databashost = "localhost"; $dbanvandare = "root"; $dblosenord = "**********"; $databas = "cykelarenan"; $anslutning = mysql_connect($databashost, $dbanvandare, $dblosenord) or die("kunde för tillfället inte ansluta till databasen!"); mysql_select_db($databas) or die("Databas problem!"); #hämtar cyklisterna och information från dem! mysql_query("SELECT * FROM cyklister") or die("Något tillfället fel med servern!"); # köp funktionen! $pris = if($saldo < $priset) { ""; else " <input type="hidden" name="button" id="button" value="Köp" />"; } # tabell med cyklisterna + köp funktionen! echo '$cyklist'; echo '$pris'; echo '$kop'; echo '</table>'; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/243125-help-with-online-based-manager-phpmysql/#findComment-1248751 Share on other sites More sharing options...
MasterACE14 Posted July 29, 2011 Share Posted July 29, 2011 this... $pris = if($saldo < $priset) { ""; else " <input type="hidden" name="button" id="button" value="Köp" />"; } should be this... $pris = if($saldo < $priset) { echo ""; } else { echo " <input type="hidden" name="button" id="button" value="Köp" />"; } Quote Link to comment https://forums.phpfreaks.com/topic/243125-help-with-online-based-manager-phpmysql/#findComment-1248910 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.