Jump to content

PHP and MySQL


Patte12

Recommended Posts

Hello.

 

I'm really new to PHP/MySQL.

I got this code:

 

$user = $_POST['user'];
$money = $_POST['money'];

$check = mysql_query("SELECT * FROM database WHERE `user`='".$user."'");
$numrows = mysql_num_rows($check);
if ($numrows == 0)
{
die ("Username does not exist \n");
}
else
{
    // Stuck!
}

 

Now if the user match any username in the database table,

i want it to "die" how much money they have so example:

 

$user = $_POST['user'];
$money = $_POST['money'];

$check = mysql_query("SELECT * FROM database WHERE `user`='".$user."'");
$numrows = mysql_num_rows($check);
if ($numrows == 0)
{
die ("Username does not exist \n");
}
else
{
    // check the money under their user
// and then returns die (their money);
}

 

But my problem is that i don't know what to check for,

should i use something like "SELECT * FROM $user" or what?.

 

I don't know how to get started can anybody point me to the right direction?.

Thank you!

Link to comment
Share on other sites

We don't know either because we haven't a clue what is in your database or what the significance of "$_POST['money']" is.

 

The database is a table with

- id

- user

- money

- pass

 

And ive deleted the $money = POST..

i don't need that i just want to return the user's money.

 

Tryed something like this

 

while($row = mysql_fetch_assoc($check))
{
	die($money);
}

 

But that doesn't return anything.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • 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.