Jump to content

Export mysql with LIMIT


daveh33

Recommended Posts

I have a script which exports numbers from a mysql database - it currently exports all numbers in a loops whilst checking if the number is in another database (reject list) - if it is, the number isn't displayed.

My code is: -

<?php
$f = $_GET['function'];
$id = $_GET['id'];
if ($f!="all" && $f!="get10k") {
include_once("header.php");
}
require_once("../dbconnect.php");
$result = mysql_query("SELECT * FROM data_lists WHERE id='$id'") or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
$tablename = $row['tablename'];
$name = $row['name'];
$lp = $row['lastprocessed'];
if ($f=="all") {
$result = mysql_query("SELECT DISTINCT(number) FROM $tablename") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$number = $row['number'];
$result1 = mysql_query("SELECT DISTINCT(number) FROM STOPS") or die(mysql_error());
$row1 = mysql_fetch_array($result1);
$stop = $row1['number'];
if ($number!=$stop) {
echo $number;
echo "<br />";
}
}
mysql_query("UPDATE data_lists SET lastupdate='$date' WHERE id='$id'") or die(mysql_error());
exit();
}

 

I am trying to duplicate this code - so instead of getting all the rows - it gets 10,000 rows, I added the field 'lastprocessed' to data_lists  so when the query is successfully executed I can record the starting point for next time the query is ran.

 

 

Can anyone offer any advise on how to complete this? All help is much appreciated

Link to comment
https://forums.phpfreaks.com/topic/85001-export-mysql-with-limit/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.