| | |
Storing checkbox values.............
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 144
Reputation:
Solved Threads: 0
Hi all,
I am storing check box values with comma separated into db like this , the code given below
but while retrieving from the db i am not able to display it properly the code is given below
its giving the o/p like this
a:3:{i:0;s:18:"vehicle Inspection";i:1;s:14:"batteryservice";i:2;s:10:"oil canhge}
i want only vehicle inspection , battery service like this...........can anybody help me pls...........i am trying this from long time.
I am storing check box values with comma separated into db like this , the code given below
php Syntax (Toggle Plain Text)
<?php include 'database.php'; $servicec = addslashes(serialize($a1)); $servicet = addslashes(serialize($b1)); $services = addslashes(serialize($c1)); $query1 = "insert into autoalto_contractor( service_category,service_type,services) values ('".$servicec."', '".$servicet."','".$services."')";
but while retrieving from the db i am not able to display it properly the code is given below
php Syntax (Toggle Plain Text)
<?php session_start(); include('database.php'); $result = mysql_query("SELECT * FROM autoalto_contractor" ); while($row = mysql_fetch_array($result)) { ?> <tr> <td width="5%"></td> <td><?echo $row['service_category'];?></td> <td><?echo $row['service_type'];?></td> <td><?echo $row['services'];?></td> </tr> <tr> <td width="5%"></td> <td colspan="4" style="background-repeat: repeat-x;" background="images/dot.jpg" height="0" width="300"></td> </tr> <? } mysql_close(); ?>
its giving the o/p like this
a:3:{i:0;s:18:"vehicle Inspection";i:1;s:14:"batteryservice";i:2;s:10:"oil canhge}
i want only vehicle inspection , battery service like this...........can anybody help me pls...........i am trying this from long time.
•
•
Join Date: Jun 2008
Posts: 144
Reputation:
Solved Threads: 0
Hi all,
i used unserialize method but its displaying like this
o/p is
emailId zipcode service_category service_type services
ishu@gmail.com 3333 Array N; N;
Instead displaying value its displaying Array so what to do now..........pls help me
i used unserialize method but its displaying like this
php Syntax (Toggle Plain Text)
<td><?echo unserialize($row['service_category']);?></td>
o/p is
emailId zipcode service_category service_type services
ishu@gmail.com 3333 Array N; N;
Instead displaying value its displaying Array so what to do now..........pls help me
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
If you are using mysql_fetch_row it returns your data as an array ... thus the array in your output.
You should manage your database output before writing it to the html page.
Something like this ...
You should manage your database output before writing it to the html page.
Something like this ...
PHP Syntax (Toggle Plain Text)
$arr = mysql_fetch_row( $result ); $str = implode( " ", $arr ); print $str;
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
You don't really say what is not working, or how?
I'm assuming your database query is giving you results,
That the results have been serialized as demonstrated above,
And you're just still having trouble unserializing the results and getting them into your <td> fields ...
If the above doesn't work you will need to be more specific about what the results you are getting are.
...
I'm assuming your database query is giving you results,
That the results have been serialized as demonstrated above,
And you're just still having trouble unserializing the results and getting them into your <td> fields ...
PHP Syntax (Toggle Plain Text)
<?php session_start(); include('database.php'); $result = mysql_query( "SELECT * FROM autoalto_contractor" ); while( $row = mysql_fetch_array( $result ) ) { $service_category = unserialize( $row['service_category'] ); $service_type = unserialize( $row['service_type'] ); $services = unserialize( $row['services'] ); print <<<endline <tr> <td width="5%"></td><!--??? WHY THIS width="5%" ???--> <td>$service_category</td> <td>$service_type</td> <td>$services</td> </tr> <tr> <td width="5%"></td><!--??? colspan="3" below ???--> <td colspan="4" style="background-repeat: repeat-x;" background="images/dot.jpg" height="0" width="300"></td> </tr> endline; } mysql_close(); ?>
If the above doesn't work you will need to be more specific about what the results you are getting are.
...
![]() |
Similar Threads
- checkbox array storage and retrieval (PHP)
- insert loop (ColdFusion)
- Remember username and password in ASP.NET2.0 (ASP.NET)
- get checkbox value (PHP)
- Storing dynamic form values in Arrays for display & insert (PHP)
Other Threads in the PHP Forum
- Previous Thread: Passing Javascript integer (id) to mysql_query
- Next Thread: Jeet Raj ( How We CAn Genrate Barcode In Php)
| Thread Tools | Search this Thread |
.htaccess ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery key library limit link login loop mail menu mlm mod_rewrite multiple mysql oop overwrite paypal pdf pdfdownload php phpvotingscript problem query radio random recursion regex remote screen script search server sessions sms soap sorting source space sql startup syntax system table tutorial update upload url validation validator variable video web xml youtube zend





