MySQL Forums
Forum List  »  PHP

PHP and MySQL not working together.
Posted by: Gordon White
Date: December 01, 2015 06:53AM

I can't get the SQL's to work in this script but they work with PHPMyadmin perfectly.

<?php

include 'config.php';

// Formulate Query
$query = "TRUNCATE TABLE data1";

// Perform Query
$result = mysql_query($query);

// Formulate Query
$sql1 = "INSERT INTO data1(`Entry`, `Name`, `Points`, `Winnings`, `HH`, `Fty`, `Attend`) SELECT a.playersid as Entry, b.name as Name, sum(a.points) as Points, sum(a.payout) as Winnings, sum(a.high_hand) as HH, sum(a.fifty_fifty) as Fty, sum(attend) as Attend FROM data a, players b where a.playersid = b.playersid group by Entry";

// Perform Query
$result1 = mysql_query($sql1);

// Formulate Query
$sql2 = "SET @ran := 0";
$sql3 = "SELECT @ran := @ran +1 AS Rank, `Name` , `Points` , `Winnings` , `HH` , `Fty` , `Attend` FROM data1 ORDER BY Points DESC LIMIT 0, 30 ";

// Perform Query
$result2 = mysqli_query($sql3);

// Use result
echo "<p>";
echo "Rank Name Points Winnings HH 50/50 Played";

while ($row = mysqli_fetch_array($result2))
{

echo $row[‘Rank’];
echo $row[‘Name’];
echo $row[‘Points’];
echo $row[‘Winnings’];
echo $row[‘HH’];
echo $row[‘Fty’];
echo $row[‘Attend’];

}

mysqli_free_result($result1);

?>

Any help is appreciated.

Thanks

Options: ReplyQuote


Subject
Written By
Posted
PHP and MySQL not working together.
December 01, 2015 06:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.