I'm looking for a triple combo listboxes where one has "book" the other "chapter" and the third "verse". The book is populated by a database table. Once book is selected then chapter is populated and then verse.
Any tutorial related to this?
Compare bible texts (and other tools): TheWheelofGod
<?php
/*'Option Explicit*/
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Read the King James Bible</title>
<script language="JavaScript" type="text/javascript">
<!--
function go(action) {
// set variables pointing to the two forms we need
var theForm = document.forms["myForm"];
var otherForm = window.parent.document.forms["myForm"];
// construct the "search" part of the URL from all the elements
var query = "?Book=" + theForm.Book.options[theForm.Book.selectedIndex].value;
query += "&Chapter=" + theForm.Chapter.options[theForm.Chapter.selectedIndex].value;
// test to see if a verse has been selected, if not we won't pass the values
if( theForm.verse.selectedIndex != -1 ) {
for( var i=0; i < theForm.verse.options.length; i++ ) {
if( theForm.verse.options[i].selected ) {
query += "&Verse=" + theForm.verse.options[i].value;
}
}
}
// either redirect this page or the child frame depending on which select was changed
if(action == "refresh") {
location.href = "showbook.php" + query;
} else {
ifrVerse.location.href = "showverse.php" + query;
}
}
//-->
</script>
</head>
<body>
<?php
/*
Dim Book
Dim Chapter
Dim Verse
/*
'This function checks to see that numerical values are valid
Function ValidateInt(SomeInt)
if IsNumeric(SomeInt) = False or SomeInt = "" then
SomeInt = 1
end if
/*
Do until RS.eof
*/
?>
<?php
/*<option if int(book) = int(RS("Book")) then response.write "selected" end if
value="
=RS("Book")
?>">=RS("Book_Title")</option>
RS.movenext
if RS.eof then
exit do
end if
loop
</select>
RS.Close
*/
?>
</td>
<td colspan="1" align="center">
<?php
/*
'This SQL statement creates a list of books
SQL1 = "Select DISTINCT(Chapter), Book FROM Bible WHERE Book = " & Book & " ORDER BY Chapter ASC"
rs.Open sql1,conn, 1
*/
?>
<?php
/* <select name="Chapter" size="5" style="width:75px;" onChange="go('refresh');" 'onchange="go2();">*/
?>
<?php
$result = mysql_query("SELECT DISTINCT chapter, book FROM bible WHERE book = " . $row['book'] . "");
/*
Do until RS.eof
*/
?>
<option <?php
/*if int(Chapter) = int(rs("Chapter")) then response.write "selected" end if*/
?> value="<?php
/*=RS("Chapter")*/
?>"><?php
/*=RS("Chapter")*/
?></option>
<?php
/*
rs.movenext
if rs.eof then
exit do
end if
Loop
*/
?>
</select>
I'm getting this error:
<select name='Chapter' size='5' style='width:150px;' onChange="go('refresh');">
<br />
<b>Warning</b>: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in <b>C:\xampp\htdocs\wheelofgod\search\cat\showbook.php</b> on line <b>192</b><br />
</select>
Compare bible texts (and other tools): TheWheelofGod
I think that in itself is fine. The problem is when I start another $sql, for populating the chapters. What things have to be rename and be distinct?
If $sql applies for the first listbox, then should i Put $sql2 for chapters? What about $result?
Can you verify the syntax making sure that it doesn't confuse between the two?
Compare bible texts (and other tools): TheWheelofGod
I think that in itself is fine. The problem is when I start another $sql, for populating the chapters. What things have to be rename and be distinct?
If $sql applies for the first listbox, then should i Put $sql2 for chapters? What about $result?
Can you verify the syntax making sure that it doesn't confuse between the two?
I think it is not fine. No one will know unless you put an error checking statement in. If you execute a query and it fails it will return FALSE instead of a resource.
If you get the "not a valid MYSQL resource" error, it means your query has failed. Use the following to check.
PHP Code:
$result = mysql_query("SELECT DISTINCT book_title, book FROM bible");
if (! $result) {
echo(mysql_error()); // remove both these lines in production
die(); // version and replace with an error handler.
}