php


How to update all values from a field using mysql?


Hello everyone I am a beginner programmer trying to update all my values under paid_status field after exporting my table out as csv. However, my export csv codes is using mysql statements instead of mysqli statements. I understand that mysql statements has been deprecated, but I only need this update to work, and I will not need to work on the file again.
Here are my export csv codes:
<?php
if(isset($_POST['submit']))
{
$conn= mysql_connect("xxxxxx", "xxxxxxx", "xxxxxxx", "xxxxxxxx") or die("Could not connect");
mysql_select_db("xxxxxxx",$conn) or die("could not connect database");
$filename = 'uploads/'.strtotime("now").'.csv';
//echo $filename;
$sql = mysql_query("SELECT paypalemail, cashbackrequested, currency from requestcashback where paid_status='PENDING'") or die(mysql_error());
//ONLY NEW CODE I ADDED IN (the while loop)
//Tried the methods I used while working with mysqli
while($sql->fetch_array()){
$results->mysql_query("UPDATE requestcashback SET paid_status = 'ACCOUNTED'")or die(mysql_error());
}
//DEFAULT EXPORT CODE AFTER THIS LINE
$num_rows = mysql_num_rows($sql);
if($num_rows >=1)
{
$row = mysql_fetch_assoc($sql);
//open of files
$fp = fopen($filename,"w");
//echo $row;
$seperator = "";
$comma = "";
foreach($row as $name => $value)
{
//to display as "name","email","lastname"
$seperator .= $comma . '' .str_replace('','""',$name);
$comma = ",";
}
$seperator .= "\n";
echo $seperator;
fputs($fp,$seperator);
//using the first query above, leaving the first row out
mysql_data_seek($sql, 0);
while($row = mysql_fetch_assoc($sql))
{
$seperator = "";
$comma = "";
foreach($row as $name => $value)
{
//to display as "name","email","lastname"
$seperator .= $comma . '' .str_replace('','""',$value);
$comma = ",";
}
$seperator .= "\n";
fputs($fp,$seperator);
}
fclose($fp);
}
else
{
echo 'No Records in the database';
}
}
?>
However, the php returned blank instead of the usual echo after a successful export.

Related Links

How to list contact us records in Magento admin?
why sql give me error “Invalid parameter number: parameter was not defined”
URLLoader Flash to grab PHP Info
Zend serialization is not storing relationship between objects
404 Error in Laravel 5.1 deployment
Mongo DB query issue
error in file “mysql4-upgrade-1.6.0.0-1.6.0.1.php” in magento 1.9.2.0 installation with sample data
Unable to reset form in codeigniter
checkbox to select item of a row table and get the amount that the user input in the from
Fetching one value from mysql using mysqli fails
Comparing current datetime with datetime from database without refreshing page
Get headers on Appengine GAE PHP
Displaying and linking Foreign Key content in PHP
how to update the data from primary key field?
How to retain the value after GET in same page?
yii CButtonColumn in gride view gives error

Categories

HOME
spring-data
events
android-studio
typelite
ontouchlistener
openxml
schema.org
softlayer
hid
website
cypher
driver
heuristics
colors
mailmerge
live-streaming
rpmbuild
office-ui-fabric
xsl-fo
significance
jitsi
social-tables
altium-designer
rxjs5
quartz.net
jpa-2.1
crud
hdmi
react-bootstrap-table
bonita
envoy
windowsiot
vcenter
python-2.x
quick-nimble
universal
seafile-server
bootstrap-sass
forms-authentication
fastlane
flipkart
git-tfs
apache-toree
webalizer
deployd
swiperefreshlayout
zend-server
kendo-treeview
perl-data-structures
portal
tablespace
django-testing
system.net.mail
declarative
dojo-build
timestamping
persistent-object-store
flipclock
ruby-on-rails-4.1
libz
rebar
device-admin
nesper
producer
jini
screwturn
redpitaya
mod-perl
particle-swarm
facebook-game-groups
codahale-metrics
virtual-channel
hints
apportable
pacman
ui-design
semicolon
jbox2d
jquery-dialog
jmenu
3des
j2mepolish
facebook-fbml
gtktextview
sqlsitemapprovider
index.dat
community-server

Resources

Encrypt Message