By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,083 Members | 1,957 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,083 IT Pros & Developers. It's quick & easy.

to display value from database

P: 2
Hi,this is the coding to display results.
<?php

// Set Variables

$mysql_server = "fdb3.awardspace.com";
$mysql_username = "876837_root";
$mysql_password = "gcesalem11";
$mysql_database = "876837_root";
$mysql_table = "results";

if(isset($_GET[regnum])){

// Mysql conection
mysql_connect("$mysql_server", "$mysql_username", "$mysql_password");
mysql_select_db("$mysql_database");

// Query db
$sql = "SELECT subject,Name,marks FROM `results` WHERE regnum='$_GET[regnum]' ";
$result = mysql_query($sql) or die(mysql_error());

echo "<p>Register Number: $_GET[regnum]</p>";

echo "<p>Name : $_GET[Name]</p>";

echo "<table border=\"1\" style=\"border-collapse: collapse\" width=\"25%\" id=\"table1\">\n<tr>\n<td><b>Subject</b></td>\n<td><b>Result</b></td>\n</tr>";

// Show results
while($row = mysql_fetch_array($result)){
echo "<tr>";
echo "<td>$row[subject]</td>";
echo "<td>$row[marks]</td>";
echo "</tr>";
}
}else{
echo "<p><b>Register Number:</b></p>\n<form method=\"GET\" action=\"index.php\">\n<p><input type=\"text\" name=\"regnum\" size=\"20\"><input type=\"submit\" value=\"Enter\"></p>\n</form>";
}
?>

in this it displays Register number in webpage by using
echo "<p>Register Number: $_GET[regnum]</p>";
next to this i have to display name from the database
i used like this
echo "<p>Name : $_GET[Name]</p>";
but name not displayed...
Any one give solution for this...
Oct 25 '11 #1
Share this Question
Share on Google+
3 Replies


zorgi
Expert 100+
P: 431
Just quick scann and I noticed this:

Expand|Select|Wrap|Line Numbers
  1. $_GET[regnum]
  2.  
should be
Expand|Select|Wrap|Line Numbers
  1. $_GET['regnum']
  2.  
SECURITY ISSUE:
Please have a look here:
http://php.net/manual/en/function.my...ape-string.php
Oct 25 '11 #2

P: 2
if(isset($_GET[regnum] && $_GET[Name]))

is it right to fetch name from database
Nov 1 '11 #3

omerbutt
100+
P: 638
hi reni ,
try printing out the GET array before doing any thing so that you now the area of the problem
Expand|Select|Wrap|Line Numbers
  1. print_r($_GET)
  2.  
REGARDS,
OMER ASLAM
Nov 2 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.