Hello, basically Ive got a description page, this page will be different depending on the product you click for its description. However its dosent seem to be working
<?php echo "<a href='http://127.0.0.1/desc.php?id=".$game->g ... ame()."</a>;" ?>
Thats where Im pretty sure the problem is happening, can anyone see a fault in that?
desc.php page works fine but desc.php?id=1, desc.php?id=2 etc wont work.
Pass Data
Moderator: General Moderators
Re: Pass Data
only thing i can notice is semi colon should be after "..like
Code: Select all
<?php echo "<a href='http://127.0.0.1/desc.php?id=".$game->getID()."'>".$game->getName()."</a>"; ?>
Re: Pass Data
Can we see the code you use to display the products?
Re: Pass Data
I fixed it! =D
I did this instead
<a href="desc.php?id=<?php echo $game->getID(); ?>
&name=<?php echo $game->getName(); ?>"><?php echo $game->getName();?></a>
But now I have a little problem, what do I put in desc.php to "know" the id for the description that was clicked?
I did this instead
<a href="desc.php?id=<?php echo $game->getID(); ?>
&name=<?php echo $game->getName(); ?>"><?php echo $game->getName();?></a>
But now I have a little problem, what do I put in desc.php to "know" the id for the description that was clicked?
Re: Pass Data
Rosaka wrote:But now I have a little problem, what do I put in desc.php to "know" the id for the description that was clicked?
Code: Select all
$_GET['id']Re: Pass Data
Hi thx, that worked kinda, its only showing the ID and not the other details I want. Heres what I got so far.
desc.php
<?php
$view->pageTitle = 'Desc';
$view->id = $_GET['id'];
$view->price = $_GET['Price'];
$view->date = $_GET['Date'];
$view->console = $_GET['Console'];
require_once('Views/desc.phtml');
desc.phtml
<?php require('template/header.phtml') ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php echo $view->id; ?>
<?php echo $view->price; ?>
<?php echo $view->date; ?>
<?php echo $view->console; ?>
</form>
<?php require('template/footer.phtml') ?>
Any idea how I can get price, date and console to show? and not just the ID
desc.php
<?php
$view->pageTitle = 'Desc';
$view->id = $_GET['id'];
$view->price = $_GET['Price'];
$view->date = $_GET['Date'];
$view->console = $_GET['Console'];
require_once('Views/desc.phtml');
desc.phtml
<?php require('template/header.phtml') ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php echo $view->id; ?>
<?php echo $view->price; ?>
<?php echo $view->date; ?>
<?php echo $view->console; ?>
</form>
<?php require('template/footer.phtml') ?>
Any idea how I can get price, date and console to show? and not just the ID
Re: Pass Data
$_GET is an array that holds paramaters passed via the URL. In your case, your URL would need to be something like http: //www.mysite.com/index.php?id=5&Price=25& ... le=console
However, I'm assuming that you are storing all this information in a DB, so you should take $_GET['id'] and query the DB for the proper information and set the variables accordingly:
However, I'm assuming that you are storing all this information in a DB, so you should take $_GET['id'] and query the DB for the proper information and set the variables accordingly:
Code: Select all
$sql = "SELECT * FROM products WHERE id = " . $_GET['id'];
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
$view->id = $_GET['id'];
$view->price = $row['price'];
$view->date = $row['date'];
$view->console = $row['console'];
Last edited by s992 on Wed Jan 12, 2011 5:26 pm, edited 1 time in total.
Re: Pass Data
Hi, I tried your advice but got the following errors
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO)
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given
Am guessing theres a problem connecting to the database? But I am already connected? I view the list of items from the database on the page, I then click that item to load up desc.php, but this is where the problem is going wrong
I cant seem to pass/retrieve the specific item.
Im a total noob at this
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO)
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given
Am guessing theres a problem connecting to the database? But I am already connected? I view the list of items from the database on the page, I then click that item to load up desc.php, but this is where the problem is going wrong
Im a total noob at this