Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If we assume this is all of the code you're running then the first query is pretty much useless since you want to parse through all the rows no matter how many. So you can skip the first three lines all together.</p> <p>Then there's the $c variable, unless you need to know how many rows you parse through this can be scrapped as well.</p> <p>Then there's the query inside the first loop, the "WHERE ID = '$c'" part is most likely what causes you to only get one inserted row. If the ID column is an auto_increment primary key the first inserted row will have a value of at least 1 but the first check you do is for an ID = 0 which returns nothing. The last iteration of a table with two rows will therefore be for an ID of 1 but there's no guarantee that there's any row with that ID but in your case there is one and I'm guessing that this is the row you're seeing in your result.</p> <p>I'm not going to try to suggest corrections for the second while loop without a bit more information about the columns such as ID1 and ID2. Maybe you could post the table definitions (the create table structure) and explain a bit further?</p> <p>As others have said, don't use mysql_ functions, these can disappear from PHP anytime as they are deprecated.</p> <p>All of this is of course based on guessing about the tables since you haven't posted the table layout or what it is you're trying to achieve.</p> <p>To get you a bit on the road here's a simpler code snippet, it's not complete but should give you the idea, <a href="http://www.php.net/manual/en/book.pdo.php" rel="nofollow">read about PDO here</a></p> <pre><code>$pdo = new PDO(&lt;insert your connection information here&gt;); $selectStmt = $pdo-&gt;query('SELECT * FROM preordertablet1'); $insertStmt = $pdo-&gt;prepare("INSERT INTO huur (ID, ID2, status, naam, Postcodehuisnummer, datum, dagen, productid, subid) VALUES (:ID1, :ID2, '1', :naam, :postcode, :datum, :dagen, :productid, :subid)"); $ID1 = 0; // Or whatever starting value you're working from. while ($row = $selectStmt-&gt;fetch(PDO::FETCH_ASSOC)) { $ID1++; $values = array("ID1" =&gt; $ID1, "ID2" =&gt; NULL, "naam" =&gt; $row['naam'], etc... $insertStmt-&gt;execute($values); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload