1

(9 replies, posted in PHP)

Thanks again Tino, I will play with this before I ask anymore questions. big_smile

2

(9 replies, posted in PHP)

Hey isn't there a way to write the same thing doing switch statment? to avoid all the if else statments?

3

(9 replies, posted in PHP)

Thanks for the great info Tino. I will remember that sir smile

4

(9 replies, posted in PHP)

Thanks for the reply bud. I figured it out and here's what I got.

$con = mysql_connect("localhost","root","");
if (!$con)
              {
  die('Could not connect: ' . mysql_error());
} mysql_select_db("stats", $con);
if ($score_compare[1]==$score_conmpare[2]) {
    mysql_query("INSERT INTO `standings` (draw) VALUES ('".$draw."')");
    mysql_query ("INSERT INTO `standings` (team1) VALUES ('".$team."')");
    mysql_query ("INSERT INTO `standings` (team2) VALUES ('".$team2."')");
    } elseif ($score_compare[1]>$score_conmpare[2]) {
    mysql_query("INSERT INTO `standings` (wins) VALUES ('".$wins."')");
    mysql_query ("INSERT INTO `standings` (team1) VALUES ('".$team."')");
    mysql_query ("INSERT INTO `standings` (loss) VALUES ('".$loss."')");
    mysql_query ("INSERT INTO `standings` (team2) VALUES ('".$loss."')");
} else {
       if ($score_compare[1]<$score_conmpare[2]) 
    mysql_query ("INSERT INTO `standings` (loss) VALUES ('".$loss."')");
    mysql_query ("INSERT INTO `standings` (team1) VALUES ('".$team."')");
    mysql_query("INSERT INTO `standings` (wins) VALUES ('".$wins."')");
    mysql_query ("INSERT INTO `standings` (team2) VALUES ('".$team2."')");
    }
mysql_close($con);

There's probably a easier way of doing this. But I'm still learning. tongue

5

(3 replies, posted in PHP)

Hard to be patient when stuck on a syntax. I mean, my other post has be patiently waiting for a reply for 2 days. It's ok I joined a different forum no biggie. Thanks

6

(3 replies, posted in PHP)

sigh never mind thanks for the help roll

correct syntax was

mysql_query("INSERT INTO `standings` (wins) VALUES ('".$wins."')");
mysql_query("INSERT INTO `standings` (draw) VALUES ('".$draw."')");

I don't understand why nobody could answer  this question.

7

(3 replies, posted in PHP)

Since nobody could answer my first question, probably cause it was impossible to explain fine lol.

Yes, I'm very new to PHP but perhaps someone could explain why this isn't inserting into my table on msql.

<?php

$wins=$_POST['winner'];
$loss=$_POST['loser'];
$draw=('1');
$streak=$_POST[''];
$team1=$_POST['select2'];
$team2=$_POST['select'];

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("stats", $con);
if ($wins==$loss){
mysql_query("INSERT INTO standings (draw,) VALUES (".$draw.")");}
else echo "false!";
mysql_close($con);
?>

I have a form with the name "winner" && "loser"
Basically I have it comparing fine, if the score is a draw I want the variable $wins && $loss to insert into table the result from $draw variable.

But it's not inserting into data base? please someone explain! thanks

8

(9 replies, posted in PHP)

Am I one of the lucky few who don't get a reply? lol yikes

9

(9 replies, posted in PHP)

Hey fellow programmers!

ok, how am I going to explain this. I'm trying to create a page that has an option to pick two different teams, followed by an input field of a score for each team. I'd like php to look at the higher value and post who won the match to a standings page. That make any sense? basically I'm trying to create a league page for my fantasy football team.

Here's what I did in php please let me know if I'm completely off, cause I seem to be able to follow php tutorials fine, but when it comes to doing my own stuff, I just have no idea what I'm doing lol. Here's the code:

/* php

<?PHP
$winner =$_POST['win']; 
$loser =$_POST['loss']; 
     if ($winner > $loser)mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("stats") or die(mysql_error());
mysql_query("INSERT INTO `standings` VALUES ('$winner', '$loser')");
Print "Your information has been successfully added to the database.";
?> 

/* form:

<html>
<body>


<form action="test.php" method="post">
win <input type="text" name="win"><br>
loss <input type="text" name = "loss"><br>
<input type="submit" value="Submit">
</form> 

</body>
</html>

Thanks so much!