tjverge Posted January 8, 2011 Share Posted January 8, 2011 <?php ob_start(); session_start(); $pagerank=2; if ($rank < $pagerank){ header('Location:main.php?id=lowrank.php'); } else{ $name1 = $_GET["name"]; $type2 = $_GET['type']; Echo "Your seach for ".$name1." gave the following results: "; $records_per_page = 15; $total = mysql_result(mysql_query("SELECT COUNT(*) FROM systems WHERE '$type2' LIKE '%$name1%'"), 0) or die(mysql_error()); $page_count = ceil($total / $records_per_page); Echo $total." Records Found"; echo "<table border=0>"; $page = 1; if (isset($_GET['page']) && $_GET['page'] >= 1 && $_GET['page'] <= $page_count) { $page = (int)$_GET['page']; } $skip = ($page - 1) * $records_per_page; $result = mysql_query("SELECT * FROM systems WHERE $type2 LIKE '%$name1%' ORDER BY Security DESC LIMIT $skip, $records_per_page") or die(mysql_error()); echo "<table border=1>"; echo "<td>System Name</td><td>Security</td><td>Class</td>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td valign =top>".$row['System Name']."</td>"; echo "<td valign =top>".round($row['Security'],1)."</td>"; echo "<td valign =top>".$row['System Type']."</td>"; echo "</tr>"; } echo "</table>"; echo "<br>"; for ($i = 1; $i <= $page_count; ++$i) { echo '<a href="main.php?id=' . $_GET['id'] .'&name='.$name1.'&type='.$type1. '&page=' . $i . '">' . $i . '</a> '; } } ?> The above code takes data entered in a form and is suppose to show the matching results, but no records are showing, it works when I replace the $name1 and $type2 with the actual values, any ideas? Link to comment https://forums.phpfreaks.com/topic/223789-no-records-pulling-from-database/ Share on other sites More sharing options...
tjverge Posted January 8, 2011 Author Share Posted January 8, 2011 Found the problem, if anyone else is having this problem I needed to switch $result = mysql_query("SELECT * FROM systems WHERE $type2 LIKE '%$name1%' ORDER BY Security DESC LIMIT $skip, $records_per_page") or die(mysql_error()); to $result = mysql_query("SELECT * FROM 'systems' WHERE '$type2' LIKE '%$name1%' ORDER BY Security DESC LIMIT $skip, $records_per_page") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/223789-no-records-pulling-from-database/#findComment-1156716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.