I have created a database "orders" in Mysql and have a table named "spaces" in that.
#
Table structure for table spaces
#
CREATE TABLE spaces (
id tinyint(4) NOT NULL auto_increment,
package varchar(50) default NULL,
amount varchar(10) default NULL,
currency varchar(4) default NULL,
duration varchar(7) default NULL,
PRIMARY KEY (id),
UNIQUE KEY id (id)
) TYPE=MyISAM;
When I am trying to fetch data from the database I am successfully able to do so but when I am trying to pass a value of field 'id' by using
<a href="test.php?id=1>Check</a>
It straight jumps to the else function. The code I am giving is as below:
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("orders",$db);
// display individual record
if ($space) {
$result = mysql_query("SELECT * FROM spaces WHERE space=$space",$db);
$myrow = mysql_fetch_array($result);
printf("Package Name: %s\n<br>", $myrow["package"]);
printf("Amount: %s\n<br>", $myrow["amount"]);
printf("Currency: %s\n<br>", $myrow["currency"]);
printf("Duration: %s\n<br>", $myrow["duration"]);
} else {
// no records to display
echo "Sorry, no records were found!";
}
?>
Can anyone help as I am a novice to Programming and Mysql both.