Hello, I'm currently using a script to retrieve values in a mysql database which can be written to and read from. The trouble is when reading it works fine although
It only retrieves 1 value on each request making it rather slow (around 20 seconds for 10 values). :p
What I need to do is either me be able to tell it how many values to return at once,
or return 10 values at once.
Sometimes it's easier to Just show you the code and pick it apart :evilgrin:
To retrieve values I use parameters so in my address bar e.g.
"http://krisando.com/serverlist.php?cmd=r&sec=101&key=entry&random=1200"
I either need to be able to do this to retrieve larger amounts of data this is for 10 values
"http://krisando.com/serverlist.php?cmd=r&sec=101&key=entry&retrieve=10&random=1200"
Helping in the littlest way would mean alot 🙂 making return 2 values even
<?php
$cmd=$_GET['cmd'];
$sec=$_GET['sec'];
$key=$_GET['key'];
$val=$_GET['val'];
$ret=1;
// Make a MySQL Connection
mysql_connect("localhost", "krisando_store", "246") or die(mysql_error());
mysql_select_db("krisando_serverlist") or die(mysql_error());
// Create a MySQL table in the selected database
//netvaron! id,gameid,var,val
$sql = "
CREATE TABLE IF NOT EXISTS `netvaron`
(
`id` int(11) NOT NULL auto_increment,
`gameid` varchar(10) default NULL,
`var` varchar(1000) default NULL,
`val` varchar(1000) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=506
";
mysql_query($sql);
// Insert a row of information into the table "netvaron"
if ($cmd==w){
mysql_query("DELETE FROM netvaron WHERE gameid='".$sec."' AND var='".$key."'")
or die(mysql_error());
mysql_query("INSERT INTO netvaron
(gameid, var ,val) VALUES('".$sec."', '".$key."' ,'".$val."') ")
or die(mysql_error());
echo '1';
}
if ($cmd==r){
// Retrieve all the data from the "netvaron" table
$result = mysql_query("SELECT * FROM netvaron WHERE gameid='".$sec."' AND var='".$key."'
ORDER BY id DESC")
or die(mysql_error());
// store the record of the "netvaron" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo $row['val'];
}
?>
Thankyou, feel free to ask questions 🙂