Explaination:
1.While updating the csv file.one of the field in table as message:
Advance Purchase Offer (Min LOS: 1) : Book 22 days in advance & get 10% discount on All Nights
In this it seprated with : now we wnat to update it as three fields like offer,los,type
in this three fields we have to update thi smessage as seprately.
2.Now what we have to do means use explode condition and we have update
3. $message=explode(':', $messages);
4.First of all we have to get that message dats from table by using fetch condition
5.we have seprate this by using sizeof the array
6.If the size is 2 r 3 like that we have to write the condition and seprate that
7.$row['id']-->IS the table id
8.trim condition is used to remove the space
PHP Coding:
1.While updating the csv file.one of the field in table as message:
Advance Purchase Offer (Min LOS: 1) : Book 22 days in advance & get 10% discount on All Nights
In this it seprated with : now we wnat to update it as three fields like offer,los,type
in this three fields we have to update thi smessage as seprately.
2.Now what we have to do means use explode condition and we have update
3. $message=explode(':', $messages);
4.First of all we have to get that message dats from table by using fetch condition
5.we have seprate this by using sizeof the array
6.If the size is 2 r 3 like that we have to write the condition and seprate that
7.$row['id']-->IS the table id
8.trim condition is used to remove the space
PHP Coding:
<?php include('db.php'); $select=mysql_query("select * from tbl"); while($row=mysql_fetch_array($select)) { $messages=$row['Message']; $message=explode(':', $messages); if(sizeof($message) == 2) { $type = trim($message[0]); $offer= trim($message[1]); mysql_query("update tbl SET offer='$offer',los='0',type='$type' where id= '".$row['id']."' "); } else { $deal_type = trim($message[0]); $los= trim($message[1]); $offer= trim($message[2]); $los = trim(str_replace(")", "", $deal_los)); $type = trim(str_replace("(Min LOS", "", $deal_type)); mysql_query("update tbl SET offer='$offer',los='$los',type='$type' where id= '".$row['id']."' "); } } ?>
No comments:
Post a Comment