When it comes to scripting by php a dropdown menu, how do I skip to the next line?
<select>
<option>...
<option>...
<option>...
<option>...
<option>...
<option>...
</select>
| SitePoint Sponsor |




When it comes to scripting by php a dropdown menu, how do I skip to the next line?
<select>
<option>...
<option>...
<option>...
<option>...
<option>...
<option>...
</select>
Compare bible texts (and other tools):
TheWheelofGod


Using \n, and making sure it is surrounded by double quotes, not single quotes.
PHP Code:echo '<option>'.$name.'</option>'."\n";

What do you mean?
Edit:
Right, how do I add a newline character to my html source code ... well devined tmapm![]()




Thanks.
Now let's say I want to retrieve the first 22 records...how does that work?
Code:$query = odbc_exec($odbc, " Select DISTINCT(recordType), Book_Title, Book FROM Bible ORDER BY Book ASC ") or die (odbc_errormsg());
Compare bible texts (and other tools):
TheWheelofGod
Don't you need a GROUP BY clause if you're using DISTINCT, or is this only for MYSQL?
Anyway throw a LIMIT 22 at the end.




No group? ok.
Well I'm using MSAccess2000.
LIMIT 22: Ok I think I need to further explain. My intention is to make 3 columns of a table where each column has 22 books listed. How do I do that?
Or is there a way of breaking 22 and inserting <tr><td></td></tr> and then continuing?
Last edited by gilgalbiblewheel; Oct 31, 2007 at 18:15.
Compare bible texts (and other tools):
TheWheelofGod

yes one way would be to use a counter. set it prior to the script then add 1 each time through the loop. check it each time through and when it hits 22 have the script print the necessary html then reset the counter and continue on with the loop. If this does not make sense let me know and I will type up an example.




Well I tried that. But maybe I didn't use it properly because at one point it was repeating each 22 times. I changed things and then it did other things...where's the right place to put it?
Compare bible texts (and other tools):
TheWheelofGod
You must have a while statement outputting the results. Just after that add
something like this. Remember to set $a to 0 at the top of the page
Code:if ($a < 22) { your outtputting statements..... $a++ } else { disconnect your database }
Or even easier I think this will work in your SQL statement
Code:SELECT TOP 22 DISTINCT(recordType), Book_Title, Book FROM Bible ORDER BY Book ASC I am not overly sure on SQL syntax
Would you require pagination of the results?
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona




Well just by looking at it the second suggestion isn't what I'm looking for because as I put DISTINCT the database DINSTINCTly has 66 books named. And what I'm looking for is to place 22 in each of the 3 columns of a table.
And the first one won't work because I did something similar putting a while statement and it gave the same results 22 times. Then I put it outside the SELECT statement and Outside the closing of the connection so that it opened and closed three times and it went through the entire 66 books 3 times.
Compare bible texts (and other tools):
TheWheelofGod




is there a way to number the SELECT statement? Write three statements and make one 1-22 then the 2nd 23-44 and the 3rd 45-66?
or a while statement or loop? or what?
Compare bible texts (and other tools):
TheWheelofGod

Well I am no expert so if someone else has a better way I would also like to see it but this code will put your data into a three column table. Unfortunately it is going to to do it across instead of down one row and then back to the top. let me know if it helps or if you have a problem.
you can see it in action here www.capephotos.net/test.php
Code://set the count variable so you can use it to control the coding $count = 1; //this is a just sets up an array to use as an example $books = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","aa","bb","cc","dd","ff","gg","hh","ii","jj","kk","ll","mm","nn"); //this starts the html code $msg = "<table> <tr>"; //if this were coming from a DB I would use a while loop foreach ($books as $book) { $msg .= "<td>$book</td>"; //this is to check and see if we are ready to start the next row in the table if we are it prints the html and resets the $count variable if ($count == 3) { $msg .="</tr><tr>"; $count = 1; } else { //this adds 1 to the $count variable $count++; } } //once it is done going through the array it closes the table $msg .="</tr> </table>"; echo $msg;




I think it comes pretty close to what I'm looking for except I would like to, in this case make the SELECT give the result IN the array. This way I can maybe place the table tags accordingly. Thanks.
But I think ( I'm new in PHP ) JavaScript is needed for the array right?
Compare bible texts (and other tools):
TheWheelofGod

well in mysql you could do the select statement and then after the query is run instead of doing the foreach loop do this
I do not know what it would be in access.Code:while ($my_array = mysql_fetch_array($my_sql)
If this does not help let me know and I will post the example again with the DB code




thanks.
Compare bible texts (and other tools):
TheWheelofGod
Bookmarks