I have 2 functions in PHP, one of them displays the ISBN and the title of a book and the other displays the editions that exist in the database based on the ISBN selected on the previous selection.
Here are the 2 functions:
ISBN - Book dropdown list:
<?php include ("includes/connections.php");
function dropdown($intIdField, $strNameField, $strTableName, $strOrderField, $strNameOrdinal, $strMethod="asc") {
echo "<select name=\"$strNameOrdinal\" onchange=\"selection($id)\">\n";
echo "<option value=\"NULL\">Select Value</option>\n";
$strQuery = "select $intIdField, $strNameField
from $strTableName
order by $strOrderField $strMethod";
$rsrcResult = mysql_query($strQuery);
while($arrayRow = mysql_fetch_assoc($rsrcResult)) {
$strA = $arrayRow["$intIdField"];
$strB = $arrayRow["$intIdField"] . " - " . $arrayRow["$strNameField"];
echo "<option value=\"$strA\">$strB</option>\n";
}
echo "</select>";
}
?>
Edition dropdown list:
<?php include ("includes/connections.php");
function dropdownEdition($intId1Field, $intId2Field, $strTableName, $strOrderField, $strNameOrdinal, $strMethod="asc") {
$intId2Field = $GLOBALS['book'];
var_dump($intId2Field);
var_dump($_POST["book"]);
echo "<select name=\"$strNameOrdinal\">\n";
echo "<option value=\"NULL\">Select Value</option>\n";
$strQuery = "SELECT $intId1Field, $intId2Field
FROM $strTableName
ORDER BY $strOrderField $strMethod";
$rsrcResult = mysql_query($strQuery);
while($arrayRow = mysql_fetch_assoc($rsrcResult)) {
$strA = $arrayRow["$intId1Field"];
echo "<option value=\"$strA\">$strA</option>\n";
}
echo "</select>";
}
?>
What I have been trying to do is pass the ISBN selected on the previous selection with a onchange function which would return the ISBN of the book but it failed a lot.
<?php
function selection($id){
echo $id;
}
?>
I know I'm terrible at this but I don't know what else to do if you could point me to a direction it would be much appreciated.
I would prefer a PHP solution rather than a JavaScript one if possible.
javascript