Hi,
I have a pretty simple script to display DB contents. Firslty, there is a page whereby a link passes a value like this file.php?text=text1 (goes from text1 up to text13)
I then have the script below to display the results:
<?php
include("dbconnect.php");
$query = "SELECT '$text' FROM questions WHERE $text IS NOT NULL";
$result = mysql_query($query);
?>
<html>
<head>
<title>comments</title>
<style>
td{font-family:arial;font-size:10pt}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="760" border="1" cellspacing="0" cellpadding="5" align="center" bordercolor="#000000">
<tr>
<td><b><font color="#FF0000">comments</font></b></td>
</tr>
<tr>
<td>
<!-- display details loop-->
<?php
while($row = mysql_fetch_array($result)){
?>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="21%" bgcolor="#FFFFCC"><b></b></td>
<td width="79%"><? echo $row[$text]?></td>
</tr>
</table>
<hr width="100%" noshade align="center">
<?php } ?>
<!-- display details loop end -->
</td>
</tr>
</table>
</body>
</html>
To test this I have entered 1 value in the cell text5 in the final row. There are 5 rows of data in the database, the first 4 have other values but are blank for text5. I then use a link like this file.phptext=text5 to display the data
however, this is just outputting 5 rows saying text5 rather than outputting 1 row with the contents of the text5 field.
Anyone got any ideas?
thanks,
Martin
At the moment, in the DB there are 5 rows of data. Only the last row has an entry for $text