PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,433 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,511 people online right now. Registration is fast and FREE... Join Now!




PHP & MYSQL

 

PHP & MYSQL, Selecting multiple data from Database

yemi

1 Jul, 2009 - 02:43 AM
Post #1

New D.I.C Head
*

Joined: 6 Nov, 2008
Posts: 9

Hello My name is Adeyemi Okeowo a young programmer from nigeria, i 'm very delighted to be a member of this forum, Below are the lines of my code which i've been having errors. This is what i want this code to do is; Select multiple check from a database(mysql) through a checkboxes of a form.
There are two pages of script,the 1st one (check_box.php) will get data out from database and be echo in the table with 2rows and 4columns the second row of the 2rows will be programmed repeat region while the checkbox will be reference with the id of the row which i have done, but i'm having problem with the other page script (select_chk.php) on how to accept the data from the post so that it can be insert into another table in the same database...

Below are the script...
CODE

//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']
?>


**Added code tags***
-jjsaw5

User is offlineProfile CardPM
+Quote Post


noorahmad

RE: PHP & MYSQL

1 Jul, 2009 - 02:50 AM
Post #2

Webmaster
Group Icon

Joined: 12 Mar, 2009
Posts: 2,018



Thanked: 125 times
Dream Kudos: 1350
My Contributions
code.gif
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 12:46AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month