14 Dec 2006 at 12:54 #1 JamesU2005 JamesU2005 Soldato Joined 30 Nov 2005 Posts 3,084 Location London Is it possible to skip a value in SQL and go onto the next one? Hope this makes sense.
14 Dec 2006 at 13:09 #2 robmiller robmiller Soldato Joined 26 Dec 2003 Posts 16,522 Location London That doesn't really make sense, no. You mean when INSERTing? Just specify the values you actually want to add: Code: INSERT INTO foo (bar, baz) VALUES ("foibles", "lol") That'll work regardless of whether foo has 2, 4 or 48 columns.
That doesn't really make sense, no. You mean when INSERTing? Just specify the values you actually want to add: Code: INSERT INTO foo (bar, baz) VALUES ("foibles", "lol") That'll work regardless of whether foo has 2, 4 or 48 columns.
14 Dec 2006 at 13:17 #3 JamesU2005 JamesU2005 Soldato OP Joined 30 Nov 2005 Posts 3,084 Location London Thought it didn't make much sense. What I am trying to do is on a webpage in php the following from my Access database. I can get the values but not in the second column. It just starts below the first column. Like below:
Thought it didn't make much sense. What I am trying to do is on a webpage in php the following from my Access database. I can get the values but not in the second column. It just starts below the first column. Like below:
14 Dec 2006 at 13:21 #4 robmiller robmiller Soldato Joined 26 Dec 2003 Posts 16,522 Location London Code: $result = mysql_query("SELECT * FROM foo"); $i = 0; while ( $row = mysql_fetch_assoc($result) ) { echo $row['bar']; if ( ++$i % 2 == 0 ) echo '<br />'; } Change the markup to suit you obviously but that's the principle :k Last edited: 14 Dec 2006
Code: $result = mysql_query("SELECT * FROM foo"); $i = 0; while ( $row = mysql_fetch_assoc($result) ) { echo $row['bar']; if ( ++$i % 2 == 0 ) echo '<br />'; } Change the markup to suit you obviously but that's the principle :k
14 Dec 2006 at 13:32 #5 toString toString Soldato Joined 18 Oct 2002 Posts 9,082 Location London Out of interest how does $i increase? Is it something to do with mysql_fetch_assoc instead of _row or _array?
Out of interest how does $i increase? Is it something to do with mysql_fetch_assoc instead of _row or _array?
14 Dec 2006 at 14:05 #6 Berserker Berserker Man of Honour Joined 4 Nov 2002 Posts 15,514 Location West Berkshire It doesn't. There's a ++$i; missing from indside the while loop.
14 Dec 2006 at 14:29 #7 toString toString Soldato Joined 18 Oct 2002 Posts 9,082 Location London Thought as much!
14 Dec 2006 at 14:43 #8 robmiller robmiller Soldato Joined 26 Dec 2003 Posts 16,522 Location London Yes, I'm stupid