Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'insert into mysql'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. I have a php script that uses <select> to display all people in a MySQL table, and then want to insert the id of all persons selected into another MySQL table. One use of this would be a way to "select" those people present. The script works, storing record ids into a seperate table. But it also records an id of "0" in addition to the record id. So every selected record is recorded with its unique id, but another record is recorded in the table with = zero! So if 4 records are selected, there will be 4 records inserted with the correct id, and 4 addition records created with id of zero. I have included the php script below, and request assistance to determine what I am doing wrong. Thank you. Wes Smith ============================================= <?php if ($_POST) { $myoptions=$_POST['options']; $selecteditems=count($myoptions); echo '<pre>'; echo htmlspecialchars(print_r($_POST,true)); echo '<pre>'; echo "Number in attendance is " . $selecteditems ; } require ('includes/mysqli_connect.php'); // Check to see if the connection failed. if (mysqli_connect_errno()) { echo "Failed to connect to MySQ:" . mysqli_connect_error(); die(); } ?> <form action="" method="post"> <select multiple name="options[]" size="20"> <?php $query = "SELECT person_id,CONCAT(last_name, ', ',first_name) AS full_name FROM Persons"; $result = mysqli_query($dbc,$query); while($row = mysqli_fetch_array($result)) { ?> <option value = "<?php echo $row['person_id'];?>"><?php echo $row['full_name']?></option> <?php } ?> </select> <input type="submit" value="submit me!" /> <?php mysqli_query($dbc, "INSERT INTO 20140420Attend(person_id) VALUES('$myoptions[0])')"); mysqli_query($dbc, "INSERT INTO 20140420Attend(person_id) VALUES('$myoptions[1])')"); mysqli_query($dbc, "INSERT INTO 20140420Attend(person_id) VALUES('$myoptions[2])')"); mysqli_query($dbc, "INSERT INTO 20140420Attend(person_id) VALUES('$myoptions[3])')"); ?> </form> ===========================
×
×
  • Create New...