| | |
PHP - sending data via hyperlink
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2007
Posts: 6
Reputation:
Solved Threads: 0
Hi,
Basically I am quite new to php but am currently connecting to a database and am trying to send data from one web page to another using the information selected in a hyperlink.
The first web page contains a table populated will all options within the database e.g. if it was computer software it would show all the brands and products. But i want to select one of these products using a hyperlink under that option in the table and use the product details selected to populate the table on the next page e.g. then showing the price and extra details for the product selected.
I don't think this requires the use of a form but am quite stuck with how to do this....i can get the hyperlink to move to the next page but the second page still displays all products rather than the one chosen!
any ideas would be greatly appreciated!
Basically I am quite new to php but am currently connecting to a database and am trying to send data from one web page to another using the information selected in a hyperlink.
The first web page contains a table populated will all options within the database e.g. if it was computer software it would show all the brands and products. But i want to select one of these products using a hyperlink under that option in the table and use the product details selected to populate the table on the next page e.g. then showing the price and extra details for the product selected.
I don't think this requires the use of a form but am quite stuck with how to do this....i can get the hyperlink to move to the next page but the second page still displays all products rather than the one chosen!
any ideas would be greatly appreciated!
have your link end in .php?brand=dell
You can add this to the end of a url and it bassicaly stores the variable (dell) in the variable name (brand) which PHP can access.
Than on the next page you can use the
$brand = $_GET['brand'];
now the brand variable equals the brand value of the link that was clicked.
You can add this to the end of a url and it bassicaly stores the variable (dell) in the variable name (brand) which PHP can access.
Than on the next page you can use the
$brand = $_GET['brand'];
now the brand variable equals the brand value of the link that was clicked.
•
•
•
•
Hi,
Basically I am quite new to php but am currently connecting to a database and am trying to send data from one web page to another using the information selected in a hyperlink.
The first web page contains a table populated will all options within the database e.g. if it was computer software it would show all the brands and products. But i want to select one of these products using a hyperlink under that option in the table and use the product details selected to populate the table on the next page e.g. then showing the price and extra details for the product selected.
I don't think this requires the use of a form but am quite stuck with how to do this....i can get the hyperlink to move to the next page but the second page still displays all products rather than the one chosen!
any ideas would be greatly appreciated!
[HTML]<a href="page.php?category=1">Shoes</a>[/HTML]
Then if a user clicks on that link, they will be taken to page.php.
When page.php is loaded, PHP will create a global Array $_GET with the parameters sent via the HTTP Request.
This Array will look like this:
[php]
<?php
// page.php
// request was: page.php?category=1
// array will look like
$_GET; // array('category'=>'1');
$_GET['category']; // 1
?>
[/php]
As you can see you can get the parameter: category via the $_GET array.
So you can use this in your database query.
Edit: lol.. Guilderpilot, looks like you got to it first...
Last edited by digital-ether; Apr 18th, 2007 at 10:03 pm.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
•
•
•
•
hello,
im a new user
and i need help !!
i need to use the hyperlink value as variable
<a href="Details.php"><?php echo "$first" . " " . "$last<br>";?></a>
i need to get $first and $fast
to use them later in the code
so how could i?
plz reply fast
best regards
zanzo
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
<?php
include 'config.php';
include 'opendb.php';
$rowsPerPage = 5;
$pageNum = 1;
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage;
$query = " SELECT FName, LName FROM user " .
" LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$first=$row['FName'];
$last=$row['LName'];
?>
<a href="Details.php"><?php echo "$first" . " " . "$last<br>";?></a>
<?php
if(mysql_num_rows($result)<1){
echo "No Results!";
}
}
include 'closedb.php';
?>
include 'config.php';
include 'opendb.php';
$rowsPerPage = 5;
$pageNum = 1;
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
$offset = ($pageNum - 1) * $rowsPerPage;
$query = " SELECT FName, LName FROM user " .
" LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die('Error, query failed');
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$first=$row['FName'];
$last=$row['LName'];
?>
<a href="Details.php"><?php echo "$first" . " " . "$last<br>";?></a>
<?php
if(mysql_num_rows($result)<1){
echo "No Results!";
}
}
include 'closedb.php';
?>
php Syntax (Toggle Plain Text)
<?php include 'config.php'; include 'opendb.php'; $rowsPerPage = 5; $pageNum = 1; if(isset($_GET['page'])) { $pageNum = $_GET['page']; } $offset = ($pageNum - 1) * $rowsPerPage; $query = " SELECT FName, LName FROM user " . " LIMIT $offset, $rowsPerPage"; $result = mysql_query($query) or die('Error, query failed'); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $first=$row['FName']; $last=$row['LName']; echo "a href=\"Details.php?first=$first&last=$last\">"; if(mysql_num_rows($result)<1){ echo "No Results!"; } } include 'closedb.php'; ?>
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
it will not work like this
coz u set $first to first and $last to last
look here what i got
a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">
coz u set $first to first and $last to last
look here what i got
a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">a href="Details.php?first=&last=">
![]() |
Similar Threads
- Encrypting Session Data (JavaScript / DHTML / AJAX)
- Easy Qu - Getting data with PHP (PHP)
- Sending single byte data (Visual Basic 4 / 5 / 6)
- sending a packet of info from C++ client to a php server (C++)
- Zend PHP Certification (PHP)
- my cpu is sending too much data to the server (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Desktop Widget for PHP application
- Next Thread: doesnt show anything
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend







