SQLITE & PHP - Beginner need some help
(1) By anonymous on 2020-05-04 15:51:51 [link]
Hi there. I am new at SQLITE & PHP and i need some help. I will make an little website to show and edit my database. I will check if an given ID is in the database. I get a link from my list.php to edit the entry: test.php?id=2 Now will will check if that id is in my database. If that id is in my db goto edit this entry and if not i need an error message. Many thanks for your help. Tobi My code atm looks ike this: <?php // check if id exist // i dont know this part ;( $db = new SQLite3("./db/MonsterDB.db"); $res = $db->query("select * from monsterinfo WHERE id='$_GET[id]'"); while ($dsatz = $res->fetchArray(SQLITE3_ASSOC)) if ($dsatz["id"] = "$_GET[id]") { echo "ID " . "$_GET[id]" ." exist"; } else { echo "ID " . "$_GET[id]" ." does not exist"; } ?> <div style="border: 1px solid #ccc; width:850px; padding: 15px 15px; margin-left: 10px;"> <table class="admin_overview_a"> <?php $db = new SQLite3("./db/MonsterDB.db"); $res = $db->query("select * from monsterinfo WHERE id='$_GET[id]'"); while ($dsatz = $res->fetchArray(SQLITE3_ASSOC)) { echo "<tr><td>Monster in bearbeitung: ".$dsatz["number"]." ".$dsatz["name"]."</td></tr>"; echo "<tr><td colspan=2 width=380> </td></tr>"; echo "<form>"; echo "<tr><td width=80 class='admin_overview_c'>ID:</td><td width=300><input type=text value=".$dsatz["id"]."></td></tr>"; echo "<tr><td width=80 class='admin_overview_c'>Nummer: </td><td width=300><input type=text value=".$dsatz["number"]."></td></tr>"; echo "<tr><td width=80 class='admin_overview_c'>Name: </td><td width=300><input type=text value=".$dsatz["name"]."></td></tr>"; echo "<tr><td width=80 class='admin_overview_c'>Name: </td><td width=300><input type=text value=".$dsatz["name2"]."></td></tr>"; echo "<tr><td width=80 class='admin_overview_c'>Name: </td><td width=300><input type=text value=".$dsatz["name3"]."></td></tr>"; echo "<tr><td> </td></tr>"; echo "<tr><td><input type=button value=speicher></td></tr>"; echo "</form>"; } $db->close(); ?> <tr><td colspan="4"> </td></tr> </table> </div>
(2) By Stephan Beal (stephan) on 2020-05-04 15:54:59 in reply to 1
> I am new at SQLITE & PHP and i need some help. I will make an little website to show and edit my database. You'll need to post this over in the PHP forums. This forum is specifically for the sqlite3 C library and some closely-related bits, not the hundreds of 3rd-party bindings for sqlite. @Forum-goers: every time you answer a PHP-specific question in this forum, it just encourages more PHP-specific traffic and a puppy angel loses its wings. Please *think of the puppies*.
(3) By anonymous on 2020-05-04 15:58:26 in reply to 2 [link]
Sorry. I have not read anything that is not also about php; ( I would still be happy if someone could help me. it's about sqlite as I use it ...
(4) By Stephan Beal (stephan) on 2020-05-04 16:07:08 in reply to 3 [link]
> I would still be happy if someone could help me. And i'm quite certain that many helpful users on the PHP forums would do so. > it's about sqlite as I use it ... More than a hundred sqlite wrappers exist for every conceivable programming language, and if even a small subset of them were supported here, we'd be overflowing in traffic. This forum is specifically for the core-most C library and a small handful of related libraries and binaries maintained by the same team.