Algoritma Overlapping

BY IN Tips & Trik Comments Off on Algoritma Overlapping

$sql=”SELECT * FROM master_card WHERE status=0″;
$result=mysql_query($sql);
while ($data=mysql_fetch_array($result))
{
$durasi=$data[‘durasi’];
if ($durasi==1)
{
$overlap=0;
$insert=0;
if (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Monday’ AND period_awal=$data[‘period_awal’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Tuesday’ AND period_awal=$data[‘period_awal’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Wednesday’ AND period_awal=$data[‘period_awal’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Thursday’ AND period_awal=$data[‘period_awal’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Friday’ AND period_awal=$data[‘period_awal’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}

if ($durasi==2)
{
$overlap=0;
$insert=0;
if ($overlap==0)
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Monday’ AND period_awal=$data[‘period_awal’] AND

period_awal=$data[‘period_akhir’] AND period_akhir=$data[‘period_awal’] AND period_akhir=$data[‘period_akhir’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Monday’ AND period_awal=$data[‘period_awal’] AND

period_awal=$data[‘period_akhir’] AND period_akhir=$data[‘period_awal’] AND period_akhir=$data[‘period_akhir’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Monday’ AND period_awal=$data[‘period_awal’] AND

period_awal=$data[‘period_akhir’] AND period_akhir=$data[‘period_awal’] AND period_akhir=$data[‘period_akhir’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Monday’ AND period_awal=$data[‘period_awal’] AND

period_awal=$data[‘period_akhir’] AND period_akhir=$data[‘period_awal’] AND period_akhir=$data[‘period_akhir’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
elseif (($overlap==0) && ($insert==0))
{
for ($i=1;$i<=8;$i++)
{
$sql1=”SELECT * FROM timetable WHERE weekday=’Monday’ AND period_awal=$data[‘period_awal’] AND

period_awal=$data[‘period_akhir’] AND period_akhir=$data[‘period_awal’] AND period_akhir=$data[‘period_akhir’]”;
$result1=mysql_query($sql1);
$numresult=mysql_num_rows($result1);
if ($numresult==1)
{
$overlap=1;
}
else
{
//insert record to timetable
$insert=1;
}
}
}

}




Comments are closed.