Jump to content

help with online based manager php/mysql!


joca91

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/243125-help-with-online-based-manager-phpmysql/
Share on other sites

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">';
}

 

 

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>

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" />";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.