CrazyCrack
Technical User
I having a little problem with that script!
I explain:
The script do half of work, the script dublicate succesfully the data from copy the row in the _hosting_order_data. But I dont understand why it dont copy the new row in the _hosting_order_option.
This is the script:
Copy data from <br><form action="admin.php?op=Order&action=CopyData&id=<? echo $_GET['id']; ?>" method="post">
<select name="CopyData">
<? $sql = "SELECT id, name FROM ".$prefix."_hosting_order";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
?> <option value="<? echo $row['id'];?>"><? echo $row['name'];?></option>
<? }
?> </select><Br><input type="submit" name="submit" value="Go"></form>
function CopyData()
{
global $db, $prefix;
$sql = "SELECT id, description, type, required FROM ".$prefix."_hosting_order_data WHERE pid = '".$_POST['CopyData']."'";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$sql = "INSERT INTO ".$prefix."_hosting_order_data SET description='".$row['description']."', type='".$row['type']."',
required='".$row['required']."', pid='".$_GET['id']."'";
$db->sql_query($sql);
if($row['type'] == 'Option')
{
$sql2 = "SELECT id FROM ".$prefix."_hosting_order_data WHERE pid = '".$_GET['id']."' ORDER BY id ASC";
$result2 = $db->sql_query($sql2);
while($row2 = $db->sql_fetchrow($result2))
$insertid = $row2['id'];
$sql2 = "SELECT description, price FROM ".$prefix."_hosting_order_options WHERE pid = '".$row['id']."'";
$result2 = $db->sql_query($sql2);
while($row2 = $db->sql_fetchrow($result2))
{
$sql = "INSERT INTO ".$prefix."_hosting_order_options SET description='".$row2['description']."', price='".$row2['price']."',
pid='".$insertid."'";
$db->sql_query($sql);
}
}
}
header("Location: admin.php?op=Order&action=editOrder&id=".$_GET['id']);
}
I explain:
The script do half of work, the script dublicate succesfully the data from copy the row in the _hosting_order_data. But I dont understand why it dont copy the new row in the _hosting_order_option.
This is the script:
Copy data from <br><form action="admin.php?op=Order&action=CopyData&id=<? echo $_GET['id']; ?>" method="post">
<select name="CopyData">
<? $sql = "SELECT id, name FROM ".$prefix."_hosting_order";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
?> <option value="<? echo $row['id'];?>"><? echo $row['name'];?></option>
<? }
?> </select><Br><input type="submit" name="submit" value="Go"></form>
function CopyData()
{
global $db, $prefix;
$sql = "SELECT id, description, type, required FROM ".$prefix."_hosting_order_data WHERE pid = '".$_POST['CopyData']."'";
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
$sql = "INSERT INTO ".$prefix."_hosting_order_data SET description='".$row['description']."', type='".$row['type']."',
required='".$row['required']."', pid='".$_GET['id']."'";
$db->sql_query($sql);
if($row['type'] == 'Option')
{
$sql2 = "SELECT id FROM ".$prefix."_hosting_order_data WHERE pid = '".$_GET['id']."' ORDER BY id ASC";
$result2 = $db->sql_query($sql2);
while($row2 = $db->sql_fetchrow($result2))
$insertid = $row2['id'];
$sql2 = "SELECT description, price FROM ".$prefix."_hosting_order_options WHERE pid = '".$row['id']."'";
$result2 = $db->sql_query($sql2);
while($row2 = $db->sql_fetchrow($result2))
{
$sql = "INSERT INTO ".$prefix."_hosting_order_options SET description='".$row2['description']."', price='".$row2['price']."',
pid='".$insertid."'";
$db->sql_query($sql);
}
}
}
header("Location: admin.php?op=Order&action=editOrder&id=".$_GET['id']);
}