Post your trick

Retriving multiple values from a single field of your database

if your having a field in your table which holds multiple values and you want to display the same.then use “spliti”
example:
company_dept is the field name.
$sql=”SELECT *from table_name”;
$ex=mysql_query($sql)
$result=mysql_fetch_array($ex);

$cmp_dept=$result['company_dept'];//when you echo this will display all the values
suppose you want single value then

$dept=spliti(”,”, $cmp_dept, 5);//this will split a string into array

$cnt=count($dept);//this will count the number of elements in the array

for output:print_r($dept)
or echo $dept[0];

spliti is case insensitive whereas split is not.
for more info visit:http://www.php.net/manual/en/function.spliti.php


Post A Trick !

How does "Kodetricks" work?

We at kodeplay like to share knowledge. With Kodetricks, even you can join us. All you need to do is post a programming related trick if you have one or rate a trick if you like someone else's.



Technology

Contact Us