the problem here is When I check 1 checkbox there's no mysql error but if the checked checkboxes are more than 1 then an error occurs. it only takes the first but the following checkboxes occurs an error.

the code can be downloaded here. the file of the problem is get_value.php

https://skydrive.live.com/embedicon.aspx/.Public/CLC.zip?cid=3e21e1e16478087a&sc=documents

please help me out getting all the values of all checked checkboxes.

in my program.... the first in the list was taken by the process but the succeedig checkboxes occurs an error. pleast tell me here the correct code of the program

I'm not sure I'm understanding where the problem is occurring...
It is when you try to add several check-boxes of the same ID element into one MySQL column/field it doesn't work?

if so, try making the element ID an array...http://www.evolt.org/node/60222

Be sure to read all the comments after the explanation. let me know if I'm on the right track.

I'm not sure I'm understanding where the problem is occurring...
It is when you try to add several check-boxes of the same ID element into one MySQL column/field it doesn't work?

if so, try making the element ID an array...http://www.evolt.org/node/60222

Be sure to read all the comments after the explanation. let me know if I'm on the right track.

some what it is. But it doesn't worked out on me. A list of checboxes that their values are coming the database.

scenario: the customer will search on the search box for available books on the crtain bookstore website. then if the user wants that item then he/she wil chck the box for adding item to cart wherein the name of that checkbox was in the form of an array. and the value was the primary key column number in the database. I wonder how to get echoing the values of all checked checkboxes from the database.

Please help me

Hi

Try to use array function on the check box as below

<input name="books_cart[]" id="books_cart[]" type="checkbox" value="<?php echo $m['books_id]; ?>"/>

it still ain't have any effect on it. kindly revise my code if you can help me. the lnk was posted above as the explanation to my question

Hi

Let we check the below code in get_vale.php

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body><table border='1'>
<tr>
<th>book id</th>
<th>book name</th>
<th>Author</th>
<th>SRP</th>
</tr><?php
        			
						
        $conn=mysql_connect('localhost','root','123')or die("cannot connect due to this error:<br/>".mysql_error());
        $selectDB=mysql_select_db("clc_books",$conn)or die("cannot connect due to this error:<br/>".mysql_error());
		
					$bookID = $_POST["bookID"];
					$limit1 = count($bookID);
					for($i=0;$i<$limit1;$i++)
					{
	
						$bookID[$i] = mysql_real_escape_string($bookID[$i]);
						
						$book_id = $bookID[$i];

        // connecting to database and stuff...  
        $sql="SELECT * FROM `clc_books_list` where book_id='$book_id'" ;
        
		$temp = mysql_query($sql,$conn);
       
        //sql output from the database
        while($row = mysql_fetch_array($temp)){?>
        <tr><td><?php echo $row['book_number'];?></td>
        <td><?php echo $row['bookname'];?></td>
        <td><?php echo $row['Author'];?></td>
        <td><?php echo $row['SRP'];?></td></tr>
        
        
     <?php }}
   ?> </body>
</html>

Hi

Let we check the below code in get_vale.php

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body><table border='1'>
<tr>
<th>book id</th>
<th>book name</th>
<th>Author</th>
<th>SRP</th>
</tr><?php
        			
						
        $conn=mysql_connect('localhost','root','123')or die("cannot connect due to this error:<br/>".mysql_error());
        $selectDB=mysql_select_db("clc_books",$conn)or die("cannot connect due to this error:<br/>".mysql_error());
		
					$bookID = $_POST["bookID"];
					$limit1 = count($bookID);
					for($i=0;$i<$limit1;$i++)
					{
	
						$bookID[$i] = mysql_real_escape_string($bookID[$i]);
						
						$book_id = $bookID[$i];

        // connecting to database and stuff...  
        $sql="SELECT * FROM `clc_books_list` where book_id='$book_id'" ;
        
		$temp = mysql_query($sql,$conn);
       
        //sql output from the database
        while($row = mysql_fetch_array($temp)){?>
        <tr><td><?php echo $row['book_number'];?></td>
        <td><?php echo $row['bookname'];?></td>
        <td><?php echo $row['Author'];?></td>
        <td><?php echo $row['SRP'];?></td></tr>
        
        
     <?php }}
   ?> </body>
</html>

Thank you so much my dear friend. I'm so thankful now I can go now to the queying of how many copies per book does the customer wants to deliver... I will create that page today... and getting thru the total price page.

hi

happy about your issue solved

hi

happy about your issue solved

hi RPV sen. can you help me out another problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.