2

I'm trying to write a php program that does sql backups and I have so many databases I want to split the processes into 3 separate ones.

My backup.php file takes in a string argument and also outputs text data for the progress of the backup.

So here is the logic I am trying to implement.

while(there is still items in the list){
 open backup.php?s=listx
 x++
}
//continue with loop and open more processes

is there a way open these pages in new tabs? I tried using curl but that doesn't seem to work and I think I've read somewhere that html tags or javascript code does not run within php code?

thanks for the help and sorry if my description is vague, just let me know and ill try to expand it. Here is my code for the mainbackup.php

<?php

// Doesnt open a new page for me..
function callpage($url)
{
  $ch = curl_init();
  $timeout = 1;
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  curl_close($ch);
}


$link = mysql_connect('host', 'user', 'password');

//set each process to handle 60 databases
$limit=60;
$count=0;
$s="";



while ($row = mysql_fetch_assoc($link)) {
//echo $row['Database'] . "\n";
if($count <$limit)
{
    $count++;
    $s.= $row['dbs']. ",";
}
else
{
    //exec('php backup.php s='$s);
    $l='localhost/backup/backup.php?s=';
    $l.=$s;
    //window.open($l);
    callpage($l);
    //substr_replace($s ,"",-1);
    //echo "\n\n\n\n\n\n\n\n\n";

    $count=0;
        $s="";
    }


}

?>

2 Answers 2

1

Thought I would post my solution here in case someone else was looking. Used php to output javascript that would open tabs. Wrote this very quickly so it also opens up the same page with an error. I assume you can fix that later.

<?php
echo "<html><body>";
$link = mysql_connect('remotehost', 'user', 'password');
$res = mysql_query("selective databases");

$limit=80;
$count=0;
$s="";
$link = '<a href="javascript:open_wins()">start backup</a><script>function open_wins(){window.open("backup.php?s=';

while ($row = mysql_fetch_assoc($res)) {
    if($count <$limit)
    {
        $count++;
        $s.= $row['dbs']. ",";
    }
    else
    {
        $link.=$s;
        $link.='");window.open("backup.php?s=';

        $count=0;
        $s="";
    }


}
$link.='");window.close();}</script></html>';
echo $link;
echo "</html></body>";
?>
Sign up to request clarification or add additional context in comments.

Comments

0

you could have the backup process create a new page for each seperate set of data (the Tabs you want) it would output to those pages, then display links on the original page to those pages holding the information (with the html to open in a new tab).

2 Comments

so you are saying have php spit out html code with a link to open those pages? ill actually give that a try!
had php output an html link that would open multiple windows and it worked like a charm. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.