Hej alle udviklere.
Håber i kan hjelpe med noget php debug som jeg ikke kan få til at virke.
- <?php
- $conn = new mysqli('localhost','','','');
- //$conn = new mysqli('localhost','root','','');
- $query = "SELECT filename,title,id FROM debug_pictures";
- $showPictures = $conn->query($query);
-
- if(isset($_POST["id"])){
- $title = $_POST["title"];
- $id = $_POST["id"];
- $sql = "UPDATE debug_pictures SET title='$title' WHERE id='$id'";
- $conn->query($sql);
- }
- ?>
-
-
- <?php if(isset($_GET["id"])){ ?>
- <form action="index.php" method="POST">
- <table cellspacing="0" cellpadding="0">
- <tr>
- <td style="width: 50px;">Titel</td>
- <td><input type="text" id="title" name="title" /></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="submit" id="submit" value="Gem" /></td>
- </tr>
- </table>
- </form><?php
- } else{
- while($row = $showPictures->fetch_assoc()){ ?>
- <a href="?id=<?php echo $row['id']; ?>"><?php echo $row['title']; ?></a><br /><?php
- }
- } ?>
Og her min sql
- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
-
- CREATE TABLE IF NOT EXISTS `debug_pictures` (
- `id` int(11) NOT NULL auto_increment,
- `filename` varchar(255) NOT NULL,
- `title` varchar(255) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-
- INSERT INTO `anderss_wi4_sde_dk`.`debug_pictures` (`id` ,`filename` ,`title`)
- VALUES ( NULL , '1.jpg', 'Billede 1'),
- ( NULL , '2.jpg', 'Billede 2' ),
- ( NULL , '3.jpg', 'Billede 3' ),
- ( NULL , '4.jpg', 'Billede 4' ),
- ( NULL , '5.jpg', 'Billede 5' );
Indlæg senest redigeret d. 19.08.2011 09:28 af Bruger #16738