Mehr ein Bild pro User/Datensatz

Vetterli99

Grünschnabel
Hallo Zusammen

Ich bstle an einer Seite, wo ich mehr als ein Bild pro Datensatz per MySQL herauslesen und anzeigen möchte. Ein Bild ist im Moment möglich, möchte aber ALLE Bilder, welche ich per Benutzer eingelesen bzw. in die DB importiert habe, auslesen und anzeigen. Wer kann mir weiterhelfen?

Hier ist der Code:

Hier editiere ich ein Datensatz; weiter unten zeige ich das Bilda n; vielleicht gibt es auch noch andere Möglichkeiten:

<?

// Includes

include ("../config.php");
// include ("../templates.php");


// Variablen Deklaration


if (!isset($_GET['idgirls'])) $_GET['idgirls'] = "";
if (!isset($_GET['name'])) $_GET['name'] = "";
if (!isset($_GET['action'])) $_GET['action'] = "";


$get_vars = array();
$get_vars['idgirls'] = htmlentities($_GET['idgirls']);
$get_vars['name'] = htmlentities($_GET['name'],ENT_QUOTES);
$get_vars['action'] = htmlentities($_GET['action']);


// Programm-Code

$conn_id = mysql_connect($HOST,$ID,$PW);
mysql_select_db($DB,$conn_id);

$result = mysql_query("select * from ".$PREFIX."_girls where idgirls = '{$get_vars['idgirls']}'");

while ($row = mysql_fetch_object($result))
{
$idgirls = $row->idgirls;
$name = $row->name;
$beschreibung = $row->beschreibung;
$alter_2 = $row->alter_2;
$telefon = $row->telefon;
$available = $row->available;
}

?>

<html>
<head>
<title>S-Meier - Administration</title>
<meta http-equiv="Content-Type" content="image/jpeg; charset=iso-8859-1">
</head>

<body bgcolor="#E8E8E8" text="#000000" link="#006600" vlink="#006600" alink="#006600">

<form name="form1" action="girls_edit_save.php" enctype="multipart/form-data" method="post">
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22" height="50"> </td>
<td height="50" colspan="2"><b><font size="4">S-Meier - Administration - Girls
- Verwalten: </font></b></td>
</tr>
<? if ($get_vars['action'] == "erfolg") { ?>
<tr>
<td width="22" height="50">&nbsp;</td>
<td height="50" colspan="2"><b><font color="#006600">Erfolg: Die &Auml;nderungen
wurden &uuml;bernommen!</font></b></td>
</tr>
<?
}
if ($get_vars['action'] == "error")
{
?>
<tr>
<td width="22" height="50">&nbsp;</td>
<td height="50" colspan="2"><b><font color="#CC0000">Fehler: Sie haben Angaben
vergessen!</font></b></td>
</tr>
<?
}
?>
<tr>
<td width="22" height="10">&nbsp;</td>
<td height="10" valign="top" colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="22" height="30">&nbsp;</td>
<td height="30" colspan="2"><b>Girls &auml;ndern:</b></td>
</tr>
<tr valign="top">
<td width="22" height="28"> </td>
<td height="28" width="150">Name des Girls:</td>
<td height="28">
<input type="text" name="neu_name" size="30" maxlength="100" value="<? echo $name ?>"> </td>
</tr>
<tr valign="top">
<td width="22" height="74"></td>
<td height="74" width="150">Beschreibung:</td>
<td height="74">
<textarea name="neu_beschreibung" id="neu_beschreibung" cols="40" rows="4"><? echo $beschreibung ?></textarea> </td>
</tr>
<tr valign="top">
<td width="22" height="28"></td>
<td height="28" width="150">Alter:</td>
<td height="28">
<input name="neu_alter_2" type="text" id="neu_alter_2" value="<? echo $alter_2 ?>" size="30" maxlength="255"></td>
</tr>
<tr valign="top">
<td height="28"></td>
<td height="28">Telefon: </td>
<td height="28"><input name="neu_telefon" type="text" id="neu_telefon" value="<? echo $telefon ?>" size="30" maxlength="255"></td>
</tr>
<tr valign="top">
<td width="22" height="28"></td>
<td height="28" width="150">Verf&uuml;gbar:</td>
<td height="28">
<select name="neu_available" id="neu_available">
<?php
if ($available == "1") echo "<option value='1' selected>Verfügbar</option>";
else echo "<option value='1'>Verfügbar</option>";
//if ($status == "2") echo "<option value='2' selected>Gelb</option>";
//else echo "<option value='2'>Gelb</option>";
if ($available == "3") echo "<option value='3' selected>Nicht Verfügbar</option>";
else echo "<option value='3'>Nicht Verfügbar</option>";
?>
</select>
<input type="hidden" name="idgirls" value="<? echo $get_vars['idgirls'] ?>"></td>
</tr>
<tr>
<td height="25">&nbsp;</td>
<td height="25">Bilder:</td>
<td height="25"><a href="images.php?idgirls=<? echo $get_vars['idgirls'] ?>">Hochladen</a></td>
</tr>
<tr>
<td height="25">&nbsp;</td>
<td height="25">&nbsp;</td>
<td height="25">
<img src="getimages.php?idgirls=<? echo $get_vars['idgirls']?>">
</td>
</tr>
<tr>
<td width="22" height="25">&nbsp;</td>
<td height="25" width="150">&nbsp;</td>
<td height="25">
<input type="image" src="speichern.gif"> </td>
</tr>
<tr>
<td width="22" height="25">&nbsp;</td>
<td height="25" colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="22" height="29">&nbsp;</td>
<td height="29" colspan="2"><a href="index.php">Hauptmen&uuml;</a>&nbsp;&nbsp;&nbsp;<a href="girls_index.php">zur&uuml;ck</a></td>
</tr>
</table>
</form>
</body>
</html>

In dieser Datei lese ich das Bild aus der DB:

<?php

// Includes

include ("../config.php");


// Variablen Deklaration


if (!isset($_GET['idgirls'])) $_GET['idgirls'] = "";
if (!isset($_GET['name'])) $_GET['name'] = "";
if (!isset($_GET['action'])) $_GET['action'] = "";


$get_vars = array();
$get_vars['idgirls'] = htmlentities($_GET['idgirls']);
$get_vars['name'] = htmlentities($_GET['name'],ENT_QUOTES);
$get_vars['action'] = htmlentities($_GET['action']);


$conn_id = mysql_connect($HOST,$ID,$PW);
mysql_select_db($DB,$conn_id);

$result = mysql_query("select * from ".$PREFIX."_bilder where idgirls = '{$get_vars['idgirls']}' order by idbilder desc limit 1");

while ($row = mysql_fetch_object($result))
{
$idgirls = $row->idgirls;
$beschreibung = $row->beschreibung;
$bytes = $row->bild;

header("Content-type: image/jpeg");echo ($bytes);
}


Was benötigt ihr noch alles?

Gruss simon, Schweiz
 
Hallo Chumper

idgirls ist auf der einten Tabelle der primary-key, auf der anderenTabelle den Hilfs-Key. Hier noch die Tabellen; welche benutzt werden:

CREATE TABLE `sMEIER_bilder` (
`idbilder` int(10) unsigned NOT NULL auto_increment,
`idgirls` int(10) unsigned default NULL,
`beschreibung` varchar(50) character set utf8 default NULL,
`bild` longblob,
PRIMARY KEY (`idbilder`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

CREATE TABLE `sMEIER_girls` (
`idgirls` int(10) unsigned NOT NULL auto_increment,
`name` varchar(255) character set utf8 default NULL,
`beschreibung` text character set utf8,
`alter_2` varchar(5) character set utf8 default NULL,
`telefon` varchar(15) character set utf8 default NULL,
`available` varchar(2) character set utf8 default NULL,
PRIMARY KEY (`idgirls`)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
 
Zurück