Hey everyone, i've been teaching myself PHP over the past couple of days, for one of my websites i need to create a script on a large scale, but currently i am trying to create the follwing - where when I select on a page, it gets the information from my db and prints the required info....
PHP GET Help
8
Hey everyone, i've been teaching myself PHP over the past couple of days, for one of my websites i need to create a script on a large scale, but currently i am trying to create the follwing -
where when I select on a page, it gets the information from my db and prints the required info....
script
............
Connect to db info here....
<a href="index.php?Link1">Link 1</a>
<a href="index.php?Link2">Link 2</a>
<a href="index.php?Link3">Link 4</a>
<a href="index.php?Link4">Link 4</a>
<?php
if ($_GET['Link1'] !=NULL) {
$liststring = "SELECT * FROM buysell WHERE subcategoryid='1'";
}
else if ($_GET['Link2'] !=NULL) {
$liststring = "SELECT * FROM buysell WHERE subcategoryid='2'";
}
else if ($_GET['Link3'] !=NULL) {
$liststring = "SELECT * FROM buysell WHERE subcategoryid='3'";
}
else {
$liststring = "SELECT * FROM buysell'";
$listInfo = mysql_query($liststring);
}
?>
<?php
while($row = mysql_fetch_array($listInfo)) {
print "<li>".$row['name']." ".$row['description']."</li>";
}
?>
....
Above is the script and it prints out all of the information, however when it comes to the if statement when wanting the content to change when I select on a link (Link1 , Link2) the information does not appear and i am left with an error.
Any help appreciated...
Stuart
where when I select on a page, it gets the information from my db and prints the required info....
script
............
Connect to db info here....
<a href="index.php?Link1">Link 1</a>
<a href="index.php?Link2">Link 2</a>
<a href="index.php?Link3">Link 4</a>
<a href="index.php?Link4">Link 4</a>
<?php
if ($_GET['Link1'] !=NULL) {
$liststring = "SELECT * FROM buysell WHERE subcategoryid='1'";
}
else if ($_GET['Link2'] !=NULL) {
$liststring = "SELECT * FROM buysell WHERE subcategoryid='2'";
}
else if ($_GET['Link3'] !=NULL) {
$liststring = "SELECT * FROM buysell WHERE subcategoryid='3'";
}
else {
$liststring = "SELECT * FROM buysell'";
$listInfo = mysql_query($liststring);
}
?>
<?php
while($row = mysql_fetch_array($listInfo)) {
print "<li>".$row['name']." ".$row['description']."</li>";
}
?>
....
Above is the script and it prints out all of the information, however when it comes to the if statement when wanting the content to change when I select on a link (Link1 , Link2) the information does not appear and i am left with an error.
Any help appreciated...
Stuart
- Ambius
- [ 1 ] Thanks
- [1] reply
- Smcminigal
- [1] reply
- Justin Hedge
- Ken Durham
- [1] reply
- mlcmartin
Next Topics on Trending Feed
-
8