Jump to content


Photo

very strange SQL problem... echoes all results when not called?


  • Please log in to reply
2 replies to this topic

#1 DaveLinger

DaveLinger
  • Members
  • PipPipPip
  • Advanced Member
  • 268 posts
  • LocationWV, USA

Posted 07 August 2006 - 02:35 AM

<html>
<head>
<link href="resultcss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
include('config/file.php');

$platform = $_POST['platform'];
$developer = $_POST['developer'];
$publisher = $_POST['publisher'];
$fletter = $_POST['fletter'];
$sortby = $_POST['sort'];
$perpage = $_POST['perpage'];
$order = $_POST['order'];

if (!$link = mysql_connect($sqlserver, $sqlusername, $sqlpassword)) {
   echo 'Could not connect to mysql';
   exit;
}

if (!mysql_select_db($sqldatabase, $link)) {
   echo 'Could not select database';
   exit;
}

if($fletter == '%'){
$query="SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' ORDER BY $sortby $order";
}ELSE{
$query="SELECT * FROM nuke_seccont WHERE secid LIKE '$platform' AND developer LIKE '$developer' AND publisher LIKE '$publisher' AND fletter='$fletter' ORDER BY $sortby $order";
}
$result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());

$numberofresults = mysql_num_rows($result);

if($numberofresults == '0'){
echo "<br>No results found matching the criteria specified!";
}else{
echo "<br><p align=\"left\">Search successful! $numberofresults results found.</p>";
echo "<table width=\"100%\" border=\"1\" style=\"border-collapse: collapse\"><tr><td><b>Game Title</b></td><td><b>Final Score</b></td><td><b>Author</b></td><td><b>Platform</b></td><td><b>Release Date</b></td><td><b>Publish Date</b></td><td><b>Hits</b></td></tr>";

$i=0;
while ($i < $numberofresults) {

$aid=mysql_result($result,$i,"aid");
$artid=mysql_result($result,$i,"artid");
$secid=mysql_result($result,$i,"secid");
$title=mysql_result($result,$i,"title");
$counter=mysql_result($result,$i,"counter");
$score6=mysql_result($result,$i,"score6");
$releasedate=mysql_result($result,$i,"releasedate");
$publishdate=mysql_result($result,$i,"publishdate");

include('includes/platforms.php');

echo "<tr><td height=\"30\">● <a href=\"review.php?artid=$artid\" target=\"_parent\"><b>$title</b></a></td>$score6<td></td><td>$aid</td><td>$section</td><td>$releasedate</td><td>$publishdate</td><td>$counter</td></tr>";

$i++;
}
echo "</table>";
}
?>
</body>
</html>

Everything works EXCEPT... it echoes every score6 result right before the table starts. So if some score6 results were 6.5, 8, 7.2, and 9, it would echo

6.587.29

then the table... with empty spots where I TOLD it to echo score6.
http://www.DaveLinger.com
dave at linger dot com

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 07 August 2006 - 02:40 AM

Look at your echo line.  Specifically where you are echoing out the $score6 in the html.

echo "
	<tr>
		<td height=\"30\">● <a href=\"review.php?artid=$artid\" target=\"_parent\"><b>$title</b></a></td>
		$score6<td></td>
		<td>$aid</td>
		<td>$section</td>
		<td>$releasedate</td>
		<td>$publishdate</td>
		<td>$counter</td>
	</tr>";

See anything wrong there?

$score6<td></td>
should be
<td>$score6</td>


#3 xec

xec
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 07 August 2006 - 05:08 AM

EDITED BY akitchin:  provided code that was both useless and wrong.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users