I have a table called “wifi” and another table called “bluetooth” on my mysql database
I have a $string from a form
if the string contains “wifi” I want to set the $tbl_name= to “wifi” ,
else set it to “bluetooth”
then send the data to the appropriate table
I havent found any example, am I doing the right thing ? Yes, I’m new 🙂
I’m doing this:
$xplatform=$_POST['platform'];
echo "made_variables ok";
// Insert data into mysql
//ifstatement decides which table to insert into
if(preg_match('/wifi/',$xplatform))
{
$tbl_name='wifi';
}
else
{
$tbl_name='bluetooth';
};
$sql="INSERT INTO $tbl_name`(`field1`,`field2`,`f3`)
VALUES('$_POST[numberlat]','$_POST[numberlng]','$_POST[name]','$_POST[website]','$_POST
[message]','$_POST[radius]','$_POST[email]','$_POST[platform]')";
$result=mysql_query($sql);
Use this:
Use that instead of
preg_match()because thepregfunctions in PHP are very expensive.