PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi all I converted the following code from asp to php the function of the script is to create a drop down box that call sit's values from a db and then when the user selects a value from the drop down it shows specific values in certain fields by the way I am using odbc to connect to my db b'cos I am using a ms sql 2k server.
The thing is it works fine in asp but when I converted it I get an error telling me that the id variable is undefined.
I see what that does ,(define the variable and then tel it what ype it is) but I still get an error on the line where I have my second sql query which goes as follows:
I see what that does ,(define the variable and then tel it what ype it is) but I still get an error on the line where I have my second sql query which goes as follows:
$strSQLa = "SELECT * FROM publications WHERE ContentId = '" . isset($id) . "'";
Another thing is that it shows nothing in my drop down list but there are values it's as if they're invisible
I think if I can sort the second problem of there not being anything in the drop down list I can get the second issue to go away 'cos then there will be a value which will be passed to the second sql statement by the way I'm just re-including the code as I changed a couple of things:
/*
if there is a variable $id
and the numeric value of $id is unequal to 0
casting $id to (int) removes the need for mysql_escape_string or similar
*/
if (isset($id) && ($id = (int)($id)) != 0)
{
// assuming ContentId is numeric
//Select the resulset that is going to be used to query data
$strSQLa = "SELECT * FROM publications WHERE ContentId='" . $id . "'";
you see the first page that you go into is called dropdown.php and when you select a value from the dropdown box it jumps to dropdown.php?id='whatever value the user selected' this is so that the user doesn't have to press on submit each time he changes a value
<script language="Javascript">
function doSel(obj)
{
for (i = 0; i < obj.length; i++)
if (objїi].selected == true)
eval(objїi].value);
}
</script>