I started to play with PHP this morning and have managed to get data from a database and output that to the screen.
I am now trying to get pass a variable onto the url and have the same page check for the existance of that variable and perform a different function.
this is the code that i have got:
<?php
$conn = new COM("ADODB.Connection" or die("Cannot start ADO"
//creates the connection object
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\websites\\php\\daNew.mdb;Mode=ReadWrite;Persist Security Info=False"
if (! isset($URLAdviceID)) {
$rs = $conn->Execute("SELECT * FROM tblAdvice WHERE ID IN (SELECT AdviceID FROM tblLinkAssociate) ORDER BY Advice"
} else {
$rs = $conn->Execute("Select * from tblLinks ORDER BY LinkName ASC"
}
?>
<HTML>
<BODY bgcolor=#FFFFFF>
<Table border=0 cellpadding=0 cellspacing=0>
<?php
if (! isset($URLAdviceID)) {
while (!$rs->EOF) {
$AdviceName = $rs->Fields("Advice"
$AdviceID = $rs->Fields("ID"?>
<TR>
<TD><a href="index.php?URLAdviceID=<?php echo $AdviceID->value ?>"><?php echo $AdviceName->value; ?></A></TD>
</TR>
<?php $rs->MoveNext();}
$rs->Close();
} else {
while (!$rs->EOF) {
$linkname = $rs->Fields("LinkName"
$linkVal = $rs->Fields("URLLink" ?>
<TR>
<TD><a href="<?php echo $linkVal->value ?>"><?php echo $linkname->value; ?></A></TD>
</TR>
<?php $rs->MoveNext();}
$rs->Close();
}
?>
</Table>
</Body>
</HTML>
i am using the isset to check to see if the url variable is set and nothing happens. when i click on a link the url variable URLAdviceID is put onto the address bar but the same page is loaded again
any help appreciate
I am now trying to get pass a variable onto the url and have the same page check for the existance of that variable and perform a different function.
this is the code that i have got:
<?php
$conn = new COM("ADODB.Connection" or die("Cannot start ADO"
//creates the connection object
$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\websites\\php\\daNew.mdb;Mode=ReadWrite;Persist Security Info=False"
if (! isset($URLAdviceID)) {
$rs = $conn->Execute("SELECT * FROM tblAdvice WHERE ID IN (SELECT AdviceID FROM tblLinkAssociate) ORDER BY Advice"
} else {
$rs = $conn->Execute("Select * from tblLinks ORDER BY LinkName ASC"
}
?>
<HTML>
<BODY bgcolor=#FFFFFF>
<Table border=0 cellpadding=0 cellspacing=0>
<?php
if (! isset($URLAdviceID)) {
while (!$rs->EOF) {
$AdviceName = $rs->Fields("Advice"
$AdviceID = $rs->Fields("ID"?>
<TR>
<TD><a href="index.php?URLAdviceID=<?php echo $AdviceID->value ?>"><?php echo $AdviceName->value; ?></A></TD>
</TR>
<?php $rs->MoveNext();}
$rs->Close();
} else {
while (!$rs->EOF) {
$linkname = $rs->Fields("LinkName"
$linkVal = $rs->Fields("URLLink" ?>
<TR>
<TD><a href="<?php echo $linkVal->value ?>"><?php echo $linkname->value; ?></A></TD>
</TR>
<?php $rs->MoveNext();}
$rs->Close();
}
?>
</Table>
</Body>
</HTML>
i am using the isset to check to see if the url variable is set and nothing happens. when i click on a link the url variable URLAdviceID is put onto the address bar but the same page is loaded again
any help appreciate