0

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

3
Contributors
8
Replies
11
Views
6 Years
Discussion Span
Last Post by masterjiraya
0

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.

Edited by PsychicTide: n/a

0

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

Edited by masterjiraya: n/a

0

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]; ?>"/>
0

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

0

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>
0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.