Hi, I've been following tutorials and trying to build a table using data from a SQLite database. The page in question is here.
So far, I can't get my page to successfully open the database (dies where highlighted). the code:
I'm sure there are other problems too, so if you see anything, please let me know; but that's where I'm stuck right now. Thanks!Code:<?php $db = "rls.sqlite"; $handle = sqlite_open($db) or die ("Unable to open database"); if ((isset($_POST['sort'])) && $_POST['sort'] == 'riverside' || 'anaheim'){ $query = "SELECT * FROM TableMoulding WHERE stocking LIKE %".$_POST['sort']."% ORDER BY part"; } elseif ((isset($_POST['sort'])) && $_POST['sort'] != 'all'){ $query = "SELECT * FROM TableMoulding WHERE remark LIKE %".$_POST['sort']."% ORDER BY part"; } else { $query = "SELECT * FROM TableMoulding ORDER BY part"; } $result = sqlite_query($handle, $query) or die ("Error in query"); function TableMoulding(){ echo "<div id=\"moulding\">"; echo "<table>"; echo "<tr>"; echo "<th>Profile</th>"; echo "<th>Species</th>"; echo "<th>Dimensions</th>"; echo "<th>Stocking Locations</th>"; echo "<th>Remarks</th>"; echo "</tr>"; while ($row = sqlite_fetch_array($result)){ echo "<tr>"; echo "<td> <a href=\"/reel/library/images/moulding/det".$row['part']."\.png\" rel=\"facebox\"> <img src=\"/reel/library/images/moulding/det".$row['part']."\.png\" height=\"100px\" width=\"100px\" alt=\"Detail ".$row['part']."</a><br> Detail ".$row['part']."</td>"; echo "<td>".$row['species']."</td>"; echo "<td>".$row['dimensions']."</td>"; echo "<td>".$row['stocking']."</td>"; echo "<td>".$row['remark']."</td>"; echo "</tr>"; } echo "</table>"; } if (sqlite_num_rows($result) > 0){ TableMoulding(); } else { die ("No results found"); } ?>
[edit]: Should this be in the php forum? Mods, please move it if so. thanks again



Reply With Quote


Bookmarks