Issue
i am trying to make an simple if exist
check for MySQL via php and then i will create an String if not exist; or if an string exist, i will update and add to the value counter = counter + 1
But now i dont now why nothing happend :s
What i am doing wrong --- i had search for the problem but i didnt has find anything..
thanks ahead
heres the code
$rankset = '';
$steamid64 = "76561198070477917";
$localmap = "de_dolls";
mysql_connect("localhost", "######", "###############") or die(mysql_error());
mysql_select_db("server") or die(mysql_error());
$check1 = mysql_query("SELECT * FROM `darkrp_missingmap` WHERE map = '$localmap'") or die(mysql_error());
while($info1 = mysql_fetch_array( $check1 ))
{
if(mysql_num_rows($info1) == 0) {
print "existiert nicht wird erstellt...";
mysql_query("SELECT server INSERT INTO darkrp_missingmap (map, count) VALUES ('$localmap', '1')");
}
else {
print "existiert wird aufgestuft...";
mysql_query("SELECT server UPDATE darkrp_missingmap SET count = count + 1 WHERE map = '$localmap'");
}
}
Solution
You can try this, you can ref [this]
$check1 = mysql_query("SELECT * FROM `darkrp_missingmap` WHERE map = '$localmap'") or die(mysql_error());
$nums = mysql_num_rows($check1);
if($nums == 0) {
// do something
}
Or you can use this sql.
SELECT COUNT(*) AS count FROM `darkrp_missingmap` WHERE map = '$localmap'
And get this query's result count
.
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$nums = $row[0]['count'];
Answered By - lighter
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.