0

I am using the below PHP script to call the ARRAY values from MYSQL DB. The script is as follows:

include "conn.php";

$sql = mysqli_query($con,"SELECT * FROM wp_db7_forms where form_id = '1'");

while($row = mysqli_fetch_assoc($sql)){
 
   //$name = $row['form_value'];
   $name_explode = explode(" , ",$row['form_value']);  
   echo "<pre>";
   print_r($name_explode);
   echo "</pre>"; 
}

The result is an array as follows|:

Array
(
    [0] => a:6:{s:12:"cfdb7_status";s:6:"unread";s:9:"your-name";s:6:"Sujith";s:10:"your-email";s:21:"sujithgnair@gmail.com";s:12:"your-subject";s:5:"Hello";s:12:"your-message";s:16:"How are you man?";s:16:"ywctm-product-id";s:4:"1840";}
)

Now in PHP how will i call a particular Column or Field from this array. For example i need to show only your-name and your-email. Rest of the columns i dont need to show in the result. How will i achieve that with PHP.

Sujith
  • 1
  • 2
    Does this answer your question? [How to use php serialize() and unserialize()](https://stackoverflow.com/questions/8641889/how-to-use-php-serialize-and-unserialize) – El_Vanja May 10 '21 at 09:49
  • 2
    Looks like a serialized string was stored inside the SQL field. So you need to [unserialize](https://www.php.net/manual/en/function.unserialize.php) it into an object, then you can retrieve the individual fields as normal. – ADyson May 10 '21 at 09:49

0 Answers0