SELECTING DATA FROM THE DATABASE

Multiple selection of data from database with a checkbox

Page 1 of 1

1 Replies - 1706 Views - Last Post: 25 June 2009 - 05:09 PM Rate Topic: -----

#1 yemi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 06-November 08

SELECTING DATA FROM THE DATABASE

Post icon  Posted 25 June 2009 - 11:39 AM

Selecting multiple data from database with a check box.

//Create Database
Create database chkboxes

//Create table
Create table tbl1

//Column of the table
Msgid
From
To
Message

<-----Below are the line of code----->

//check_box.php
<?php
$con = mysql_connect('localhost','root','')or die(mysql_error());
$db = mysql_select_db('chkboxes',$con)or die(mysql_error());
$query = mysql_query("SELECT * FROM tbl1")or die(mysql_error());
?><form Method="post" Action="select_chk.php" >
<?php  
while($result = mysql_fetch_assoc($query))
{
$i++;
?>
	  <tr>
		<td width="20%" align="center">
		<input name="<?php echo $result['Msgid']?>" type="checkbox" id="<?php echo $result['Msgid']?>" value="<?php echo $result['Msgid']?>">
		</label></td>
		<td width="20%" align="center"><?php echo $result['tFrom']?></td>
		<td width="20%" align="center"><?php echo $result['tTo']?></td>
		<td width="20%" align="center"><?php echo $result['Subject']?></td>
		<td width="20%" align="center"><?php echo $result['Message']?> </td>
	  </tr>
<?php
}
?>
	  <tr>
		<td align="center"><input type="submit" name="Submit" value="Submit" /></td>
<td align="center"> </td>
		<td align="center"> </td>
		<td align="center"> </td>
		<td align="center"> </td>
	  </tr>
	</table>
  </form>


//select_chk.php
<?php
$con = mysql_connect('localhost','root','duduyemi')or die(mysql_error());
$db = mysql_select_db('chkboxes',$con)or die(mysql_error());
$query = mysql_query("select * from tbl1");

$i=0;
while($r = mysql_fetch_array($query))
{
$msg = $r['Msgid'];
if(isset($_POST[$msg])!=NULL)
{
$i++;
mysql_query("select * from tbl1 Where Msgid=$msg")or die(mysql_error());
}
}http://www.dreamincode.net/forums/showforum88.htm
echo "Result".$i['tFrom']
?>



Is This A Good Question/Topic? 0
  • +

Replies To: SELECTING DATA FROM THE DATABASE

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3099
  • View blog
  • Posts: 10,888
  • Joined: 08-August 08

Re: SELECTING DATA FROM THE DATABASE

Posted 25 June 2009 - 05:09 PM

You'd get a better response if you made some effort to describe what exactly is not working, and where you think the problem is.

From just scanning your code I can tell you that the url you've got at the end is going to cause an error.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1