Indsætte et billede i databasen?
Hej.Jeg har et afstemningssystemet,
og kunne godt tænke mig at ændre lidt på det.
Jeg vil gerne have muligheden for at sætte et billede ind ud for et valg, samt at vise billedet på stats siden.
Hvordan ændrer jeg databasen??
Her er databasen:
CREATE TABLE `ip` (
`ip` text NOT NULL,
`pollid` text NOT NULL
);
CREATE TABLE `poll_option` (
`id` bigint(20) NOT NULL default '0',
`option` text NOT NULL,
`count` bigint(20) NOT NULL default '0',
`idnum` bigint(20) NOT NULL auto_increment,
PRIMARY KEY (`idnum`)
);
CREATE TABLE `polls` (
`email` text NOT NULL,
`name` text NOT NULL,
`question` text NOT NULL,
`redirect` text NOT NULL,
`id` bigint(20) NOT NULL auto_increment,
PRIMARY KEY (`id`)
);
CREATE TABLE `user` (
`first` varchar(255) NOT NULL default '',
`last` varchar(255) NOT NULL default '',
`email` varchar(255) NOT NULL default '',
`pass` varchar(255) NOT NULL default '',
`actcode` varchar(255) NOT NULL default '',
`act` varchar(255) NOT NULL default '',
PRIMARY KEY (`email`)
);
Og hvordan kalder jeg billedet på siden her?
view.php
<?php
if (!isset($_SESSION['email'])){
include('../db.php');
}
//include('../db.php');
$sqll = "SELECT * FROM polls WHERE email='$_SESSION[email]' ORDER BY name ASC";
$resultl = mysql_query($sqll);
$number = mysql_num_rows($resultl);
if (!isset($_GET['poll_text'])){
if (!isset($poll_text)) {
echo"
Hvilken afstemning vil du se?<table>";
for ($r = 0; $r < $number; $r++){
$poll = mysql_fetch_assoc($resultl);
echo '<tr><td>
<a href="'.$_SERVER[PHP_SELF].'?poll=view&poll_text='.$poll['id'].'">'.$poll['name'].'</a></td></tr>';
}
echo"</table> <a href=\"logged.php\">Tilbage til hovedsiden</a>";
}
}
else{
$code = $_GET['poll_text'];
$sql = mysql_query("SELECT * FROM poll_option WHERE id='$code' ORDER BY idnum ASC");
$sqls = mysql_query("SELECT * FROM polls WHERE id='$code' ORDER BY name ASC");
$polls = mysql_fetch_assoc($sqls);
if (!$polls){
echo'<h2>Error</h2>
This poll doesn\'t exist. It may have been deleted<br>';
}
else{
$numbers = mysql_num_rows($sql);
echo "<b>".$polls['name']."</b><br><b>".$polls['question']."</b><br>";
echo '
<form action="'.$poll_url.'includes/poll/vote.php?poll_num='.$polls['id'].'" method="post">';
$lett = 1;
for ($e = 0; $e < $numbers; $e++){
$rows = mysql_fetch_assoc($sql);
echo '<input type="radio" name="poll'.$rows["id"].'" value="'.$rows["option"].'"> '.$rows["option"].'<br>';
$lett++;
}
echo '
<br>
<input type="submit" name="submit" value="Vote!">
</form>';
}
if(isset($_SESSION['email'])){
echo'
<a href="logged.php">Tilbage til hovedsiden</a>';
}
echo "<div class=\"powered\"><p>Powered By <a href=\"$poll_url\">$poll_url</a></p></div>";
}
?>
Mvh
Rasmussen