tags:

views:

24

answers:

0

In the following code else portion & the while loop inside if is not working........please some one help.......

<?php

include_once('config.php');
$db = oci_new_connect(ORAUSER,ORAPASS,"localhost/XE");

$url_name=$_POST['textfield'];
$keyword_name=$_POST['textarea'];
$url_type=$_POST['RadioGroup1'];
$anchor_text=$_POST['textfield2'];
$description=$_POST['textarea2'];
$country=$_POST['textfield3'];
$array_keyword=explode(',',$keyword_name);
$array_len=count($array_keyword);



for($i=0;$i<$array_len;$i++)
{
    $keyword_verify="SELECT k_ID from SE_keyword where k_Name=$array_keyword[$i]"; 
    $result_keyword=oci_parse($db,$keyword_verify);
    oci_execute($result_keyword);
    echo $array_keyword[$i];

//$temp=1;
if($result_keyword)
{
            echo "executing if";
            while($row = oci_fetch_array($result_keyword))
            {
              $keyword_id_exist=$row['k_ID'];
              echo "before insert";
              $sql_keyword_url_1="INSERT INTO SE_keyword_URL(k_ID,url_ID) VALUES($keyword_id_exist,$temp)";
              $insert_keyword_url_1=oci_parse($db,$sql_keyword_url_1);
              oci_execute($insert_keyword_url_1);

            }
            echo "after while";

}

else
{
echo "executing else";
$sql_seq="select SE_seq_keyword.nextval SE_seq_keyword from dual"; 
          $result=oci_parse($db,$sql_seq);

        oci_execute($result);   
        if($result) 
        {
          while($row = oci_fetch_array($result))
          { 

              $temp_keyword=$row['SE_SEQ_KEYWORD'];
              echo $temp_keyword;
              //echo " seq no. : ".$row['SEQ_URL1']."<br>";           
          }
        }

$sql_keyword="INSERT INTO SE_keyword(k_ID,k_NAME) VALUES($temp_keyword,:key)";

$insert_keyword=oci_parse($db,$sql_keyword);
oci_bind_by_name($insert_keyword, ':key', $array_keyword[$i]);
oci_execute($insert_keyword);   

$sql_keyword_url_2="INSERT INTO SE_keyword_URL(k_ID,url_ID) VALUES($temp_keyword,$temp) ";
$insert_keyword_url_2=oci_parse($db,$sql_keyword_url_2);
oci_execute($insert_keyword_url_2);
}
}

?>