Note: This question is posted here
hello everybody,
I have a predefind list of 15 keywords and there is mysql table against each keyword. Now what i want to do is that
first i want to check a keyword and then insert it into the relevant table. This process continue agian and again under foreach
loop.
My question is what kind of approach should i used i.e is it with if else statements, like
foreach($keyword as $key=>$val)
{
if($val==='keyword1'
{
$query="insert into keyword1_tab values('', $val);
$rs=mysql_query($query) or die(mysql_error());
}
else
if($val==='keyword2')
{
$query="insert into keyword2_tab values('', $val);
$rs=mysql_query($query) or die(mysql_error());
}
else
.
.
.
.
.
else
if($val==='keyword15')
{
$query="insert into keyword3_tab values('', $val);
$rs=mysql_query($query) or die(mysql_error());
}
}
Or something else is used for this which can maintain the speed and consistency.
1 Answer