View Full Version : identify entire row
loonatik
04-14-2003, 12:09 AM
What index type (primary,index,unique) identifies the entire row? So that when I call it from a page (page.php?id=2), it will display information from row 2 only. Thanks.
Spookster
04-14-2003, 12:22 AM
A primary key field is what is used to uniquely identify a record in a database.
loonatik
04-14-2003, 12:26 AM
i have this then on my page but it doesnt display correctly.
if($jokeID != ""){
mysql_connect ("localhost", "username", "password");
mysql_select_db ("demo_db");
$result = mysql_query("SELECT $jokeID FROM jokes");
$row = mysql_fetch_array($result);
echo("<P>".$row["jokeTitle"]." ".$row["jokeText"]."</P>");
}
else{
echo "<a href='jh.php3?jokeID=1'>click to display joke 1</a>";
echo "<a href='jh.php3?jokeID=2'>click to display joke 2</a>";
}
where jokeID is the primary key and the keyname is "primary".
thanks.
missing-score
04-15-2003, 12:31 AM
if($jokeID != ""){
mysql_connect ("localhost", "username", "password");
mysql_select_db ("demo_db");
$result = mysql_query("SELECT * FROM jokes WHERE JokeId='$jokeID';"); // Added * ( select all colums ) and a WHERE clause to this line
$row = mysql_fetch_array($result);
echo("<P>".$row["jokeTitle"]." ".$row["jokeText"]."</P>");
}
else{
echo "<a href='jh.php3?jokeID=1'>click to display joke 1</a>";
echo "<a href='jh.php3?jokeID=2'>click to display joke 2</a>";
}
That should work.
PS: I know Im not a mod, so I shouldnt be telling you what to do, but could you put PHP code in [php] blocks, cos it is so much easier to read. Thanks :D
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.