I have a issue with getting a single varible via url and using php to query mysql database and display results from the row the varible occupy's. I've been working on this for about 3 days and have found hundreds of toturials online but none seem to be affective
Here is the link used to pass the varible via url to the sample.php
<a href="sample.ph p?CustomerID=3" >click here</a>
the sample.php is supppose to retrieve the variable and display the information associated with it like this..
[PHP]
<?php
$CustomerID = isset($_REQUEST['CustomerID']) ? intval($Custome rID) : 0;
if($CustomerID < 0) { $CustomerID = 0;}
$usr = "atl";
$pwd = "XXXXX";
$db = "XXXXXX XXXXX";
$host = "localhost" ;
# connect to database
$cid = mysql_connect($ host,$usr,$pwd) ;
mysql_select_db ($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
$sql = "SELECT * FROM Registration1 WHERE CustomerID = {$CustomerID}";
mysql_query($sq l);
?>
<? echo $variablename; ?>
<?
$i=0;
while($row = @mysql_fetch_ar ray($result)) {
$RetailPrice=my sql_result($res ult,$i,"RetailP rice");
$AlbumName=mysq l_result($resul t,$i,"AlbumName ");
$Month=mysql_re sult($result,$i ,"Month");
$Day=mysql_resu lt($result,$i," Day");
$Year=mysql_res ult($result,$i, "Year");
?>
[/PHP]
The result from the database would passed to a html document like so
<html>
<head>
<title>Untitled </title>
</head>
<body>
<? echo $RetailPrice; ?>
<? echo $AlbumName; ?>
<? echo $Month; ?>
<? echo $Day; ?>
<? echo $Year; ?>
</body>
</html>
when the link is pressed the value can be seen in the address bar but the sample page only displays a blank page..any thoughts?
Here is the link used to pass the varible via url to the sample.php
<a href="sample.ph p?CustomerID=3" >click here</a>
the sample.php is supppose to retrieve the variable and display the information associated with it like this..
[PHP]
<?php
$CustomerID = isset($_REQUEST['CustomerID']) ? intval($Custome rID) : 0;
if($CustomerID < 0) { $CustomerID = 0;}
$usr = "atl";
$pwd = "XXXXX";
$db = "XXXXXX XXXXX";
$host = "localhost" ;
# connect to database
$cid = mysql_connect($ host,$usr,$pwd) ;
mysql_select_db ($db);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }
$sql = "SELECT * FROM Registration1 WHERE CustomerID = {$CustomerID}";
mysql_query($sq l);
?>
<? echo $variablename; ?>
<?
$i=0;
while($row = @mysql_fetch_ar ray($result)) {
$RetailPrice=my sql_result($res ult,$i,"RetailP rice");
$AlbumName=mysq l_result($resul t,$i,"AlbumName ");
$Month=mysql_re sult($result,$i ,"Month");
$Day=mysql_resu lt($result,$i," Day");
$Year=mysql_res ult($result,$i, "Year");
?>
[/PHP]
The result from the database would passed to a html document like so
<html>
<head>
<title>Untitled </title>
</head>
<body>
<? echo $RetailPrice; ?>
<? echo $AlbumName; ?>
<? echo $Month; ?>
<? echo $Day; ?>
<? echo $Year; ?>
</body>
</html>
when the link is pressed the value can be seen in the address bar but the sample page only displays a blank page..any thoughts?
Comment