Hello all I need fast answer on this: How i can change(or) reset value ["referalvisits"] to ZERO?
let's say that there is some value: for example 23220
I need reset it to zero and count again from zero..
""

<th>Referral Visits</th>
<td>&nbsp;&nbsp;<? echo $row["referalvisits"]; ?></td>

""

thank you alot
I will send 5$ on alertpay if you will resolve my problem..

Dani AI

Generated

Short, practical clarification and a safe path forward.

Changing the value you fetched into PHP only changes the copy in memory — it does not update the database. That makes ’s in-memory trick useful for display but not for a permanent reset; the fetch functions give you an associative array representing the row, so setting the array index to 0 won’t persist. (php.net)

To make the reset permanent, run a proper UPDATE against your users table, but do it safely: avoid the old mysql_* functions (they were deprecated/removed) and don’t concatenate user input into SQL. Use PDO or mysqli with prepared statements and check the affected-rows or run a follow-up SELECT to verify the change. Example (PDO style):

$stmt = $pdo->prepare('UPDATE users SET referalvisits = 0 WHERE username = :u');
$stmt->execute([':u' => $username]);

Use prepared statements and parameter binding to prevent injection. (wiki.php.net)

If history matters, consider a different model: either keep a reset timestamp on the user record or store each referral visit as a row (user_id + visited_at). Then compute the current count with COUNT(...) since the reset time. That preserves audit/history and makes “reset” a simple timestamp update instead of destructive data changes. (mysqltutorial.org)

Troubleshooting notes tied to the replies above: asked for full code — when you update, remember an UPDATE returns success/boolean (not a resultset), so you can’t fetch rows directly from it; run SELECT if you need to read the value back, or check affected_rows/rowCount. Always back up the DB before mass updates, test in a dev copy, and restrict the WHERE clause so you don’t accidentally zero every user. (php.net)

are you retrieving value from database ??
i think you are using while loop..
and fetching result in $row ....

so give me more info about this??

$row["referalvisits"]=0;

add this to where you want to make that variable 0.

That is all you should do.

That means $row["referalvisits"] is an ordinary array variable which you set its values from db.

Also php is free enjoy it. You dont need to pay someone to ask a question about php .

Thanks

post your full code ....

$sql="Update yob_users SET referalvisits='0' where  username='$user' ";

$result = mysql_query($sql);
$row = mysql_fetch_array($result);

by using this you set value for referalvisits 0

then check referalvisits or declare variable count
check visits & increment count++
then set referalvisit with that count and dispaly referalvisits using echo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.