Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('index.php');
- include('db.php');
- ini_set('auto_detect_line_endings',TRUE);
- /*
- if($_GET['reset'] == 1)
- mysqli_query($sql,'TRUNCATE expressinput') or die(mysqli_error($sql));
- if($_GET['reset'] == 2)
- mysqli_query($sql,'TRUNCATE expresskeywords') or die(mysqli_error($sql));
- */
- echo "<br>";
- if ($_POST['companies'] && is_numeric($_POST['searchid'])) {
- $mydata = explode("\n",$_POST['companies']);
- $searchid = mysqli_real_escape_string($sql,$_POST['searchid']);
- if( $stmt = mysqli_prepare($sql,"SELECT id FROM schedule WHERE id=?")) {
- mysqli_stmt_bind_param($stmt,"i",$searchid);
- mysqli_stmt_execute($stmt);
- mysqli_stmt_store_result($stmt);
- if(mysqli_stmt_num_rows($stmt) == 0)
- { echo "No such searchid: $searchid<br>";exit; }
- } else { echo "Mysql error\n"; exit; }
- mysqli_stmt_close($stmt);
- foreach($mydata as $piece)
- {
- $piece = str_replace("\r","",trim(mysqli_real_escape_string($sql,$piece)));
- if (strlen($piece) > 3)
- {
- if( $stmt = mysqli_prepare($sql,'SELECT id FROM input WHERE searchid =? AND company=?'))
- {
- mysqli_stmt_bind_param($stmt,"is",$searchid,$piece);
- mysqli_stmt_execute($stmt);
- mysqli_stmt_store_result($stmt);
- if(mysqli_stmt_num_rows($stmt) == 0)
- if( $stmt = mysqli_prepare($sql,'INSERT INTO input (searchid,company,status) VALUES (?,?,"active")'))
- {
- mysqli_stmt_bind_param($stmt,"is",$searchid,$piece);
- mysqli_stmt_execute($stmt);
- printf("%d Row inserted with '$piece'<br>", mysqli_stmt_affected_rows($stmt));
- mysqli_stmt_close($stmt);
- } else { echo "Mysql error\n"; exit; }
- } else { echo "Mysql error\n"; exit; }
- }
- }
- echo "<br><br><b>COMPANIES SUCCESSFULLY INSERTED FOR SEARCHID $searchid</b><br>";
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Scheduled Tasks - Companies Importer</title>
- </head>
- <body>
- <p><b>Data will be added to the input table for the given searchid (Scheduled Task ID).</b></p>
- <form action="" method="post" name="form1" id="form1">
- Input companies one per line below for searchid : <select name="searchid"><?php
- $searchids = mysqli_query($sql,'SELECT id FROM schedule') or die(mysqli_error($sql));
- while($rowu = mysqli_fetch_array($searchids))
- echo '<option value="'. $rowu[0] .'">'. $rowu[0] .'</option>';
- ?></select><br />
- <textarea rows="30" cols="50" name="companies"></textarea>
- <input type="submit" name="Submit" value="Submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement