- Home
- Categorie
- Coding e Sistemistica
- Coding
- [PHP]problema visualizzazione immagini
-
la normalizzazione l'ho totalmente ignorata,lo so..
-- phpMyAdmin SQL Dump
-- version 2.6.1-- Host: localhost
-- Generato il: 31 Mag, 2008 at 06:04 PM
-- Versione MySQL: 4.1.9
-- Versione PHP: 4.3.10-- Database:
guest_book
--
-- Struttura della tabellamessaggiCREATE TABLE
messaggi(
id_userint(10) NOT NULL auto_increment,
id_cartellatinyint(1) default NULL,
usernamevarchar(65) NOT NULL default '',
passwordvarchar(65) NOT NULL default '',
uservarchar(20) NOT NULL default '',
gendervarchar(10) NOT NULL default '',
date_of_birthdate NOT NULL default '0000-00-00',
countryvarchar(30) NOT NULL default '',
test_arousal_photo1tinyint(3) default NULL,
test_valence_photo1tinyint(3) default NULL,
test_arousal_photo2tinyint(3) default NULL,
test_valence_photo2tinyint(3) default NULL,
test_arousal_photo3tinyint(3) default NULL,
test_valence_photo3tinyint(3) default NULL,
test_arousal_photo4tinyint(3) default NULL,
test_valence_photo4tinyint(3) default NULL,
test_arousal_photo5tinyint(3) default NULL,
test_valence_photo5tinyint(3) default NULL,
test_arousal_photo6tinyint(3) default NULL,
test_valence_photo6tinyint(3) default NULL,
test_arousal_photo7tinyint(3) default NULL,
test_valence_photo7tinyint(3) default NULL,
test_arousal_photo8tinyint(3) default NULL,
test_valence_photo8tinyint(3) default NULL,
test_arousal_photo9tinyint(3) default NULL,
test_valence_photo9tinyint(3) default NULL,
test_arousal_photo10tinyint(3) default NULL,
test_valence_photo10tinyint(3) default NULL,
test_arousal_photo11tinyint(3) default NULL,
test_valence_photo11tinyint(3) default NULL,
test_arousal_photo12tinyint(3) default NULL,
test_valence_photo12tinyint(3) default NULL,
test_arousal_photo13tinyint(3) default NULL,
test_valence_photo13tinyint(3) default NULL,
test_arousal_photo14tinyint(3) default NULL,
test_valence_photo14tinyint(3) default NULL,
test_arousal_photo15tinyint(3) default NULL,
test_valence_photo15tinyint(3) default NULL,
test_arousal_photo16tinyint(3) default NULL,
test_valence_photo16tinyint(3) default NULL,
test_arousal_photo17tinyint(3) default NULL,
test_valence_photo17tinyint(3) default NULL,
test_arousal_photo18tinyint(3) default NULL,
test_valence_photo18tinyint(3) default NULL,
test_arousal_photo19tinyint(3) default NULL,
test_valence_photo19tinyint(3) default NULL,
test_arousal_photo20tinyint(3) default NULL,
test_valence_photo20tinyint(3) default NULL,
test_arousal_photo21tinyint(3) default NULL,
test_valence_photo21tinyint(3) default NULL,
test_arousal_photo22tinyint(3) default NULL,
test_valence_photo22tinyint(3) default NULL,
test_arousal_photo23tinyint(3) default NULL,
test_valence_photo23tinyint(3) default NULL,
test_arousal_photo24tinyint(3) default NULL,
test_valence_photo24tinyint(3) default NULL,
test_arousal_photo25tinyint(3) default NULL,
test_valence_photo25tinyint(3) default NULL,
test_arousal_photo26tinyint(3) default NULL,
test_valence_photo26tinyint(3) default NULL,
test_arousal_photo27tinyint(3) default NULL,
test_valence_photo27tinyint(3) default NULL,
test_arousal_photo28tinyint(3) default NULL,
test_valence_photo28tinyint(3) default NULL,
test_arousal_photo29tinyint(3) default NULL,
test_valence_photo29tinyint(3) default NULL,
test_arousal_photo30tinyint(3) default NULL,
test_valence_photo30tinyint(3) default NULL,
test_arousal_photo31tinyint(3) default NULL,
test_valence_photo31tinyint(3) default NULL,
test_arousal_ foto32tinyint(3) default NULL,
test_valence_photo32tinyint(3) default NULL,
test_arousal_ foto33tinyint(3) default NULL,
test_valence_photo33tinyint(3) default NULL,
test_arousal_ foto34tinyint(3) default NULL,
test_valence_photo34tinyint(3) default NULL,
test_arousal_ foto35tinyint(3) default NULL,
test_valence_photo35tinyint(3) default NULL,
test_arousal_ foto36tinyint(3) default NULL,
test_valence_photo36tinyint(3) default NULL,
test_arousal_ foto37tinyint(3) default NULL,
test_valence_photo37tinyint(3) default NULL,
test_arousal_ foto38tinyint(3) default NULL,
test_valence_photo38tinyint(3) default NULL,
test_arousal_ foto39tinyint(3) default NULL,
test_valence_photo39tinyint(3) default NULL,
test_arousal_ foto40tinyint(3) default NULL,
test_valence_photo40tinyint(3) default NULL,
test_arousal_ foto41tinyint(3) default NULL,
test_valence_photo41tinyint(3) default NULL,
test_arousal_ foto42tinyint(3) default NULL,
test_valence_photo42tinyint(3) default NULL,
test_arousal_ foto43tinyint(3) default NULL,
test_valence_photo43tinyint(3) default NULL,
test_arousal_ foto44tinyint(3) default NULL,
test_valence_photo44tinyint(3) default NULL,
test_arousal_ foto45tinyint(3) default NULL,
test_valence_photo45tinyint(3) default NULL,
test_arousal_ foto46tinyint(3) default NULL,
test_valence_photo46tinyint(3) default NULL,
test_arousal_ foto47tinyint(3) default NULL,
test_valence_photo47tinyint(3) default NULL,
test_arousal_ foto48tinyint(3) default NULL,
test_valence_photo48tinyint(3) default NULL,
test_arousal_ foto49tinyint(3) default NULL,
test_valence_photo49tinyint(3) default NULL,
test_arousal_ foto50tinyint(3) default NULL,
test_valence_photo50tinyint(3) default NULL,
datedatetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id_user)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=878 ;-- Dump dei dati per la tabella
messaggiINSERT INTO
messaggiVALUES (1, 0, 'g', 'b2f5ff47436671b6e533d8dc3614845d', '0', '0', '0000-00-00', 'selected', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2008-05-31 04:51:10');
INSERT INTOmessaggiVALUES (872, 0, 'u', '7b774effe4a349c6dd82ad4f4f21d34c', 'researcher', 'female', '1952-09-24', 'LA', 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 2, -2, 0, -1, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2008-05-31 05:05:25');
-
Ok ora fammi sapere che cosa vuoi inserire insieme a $id_cartella e dove inserire (in che campi)


-
grazie:
in questo passaggio
<?php
$connessione=mysql_connect("localhost", "
$selezione_db=mysql_select_db("guest_book", $connessione);
$query = mysql_query("SELECT id_user, date FROM messaggi ORDER BY date DESC limit 1");
while($riga = mysql_fetch_assoc($query))
{
$id_user = $riga['id_user'];
}
$id_cartella = substr($id_user, -1, 1);
$cartella = "fotos/".$id_cartella ;
$image_src ="fotos/" . $id_cartella . "fotos/"."1" . ".jpg";
echo "<img src="$image_src">";
?>vorrei inserire il valore
$id_cartella = substr($id_user, -1, 1);
$id_cartella = che sara' da 0 a 9
inserirlo nel campoid_cartella del tabase
-
ho questa variabile:
$id_cartella = substr($id_user, -1, 1);
l'echo di $id_cartella = un numero,nel db ho creato un campo id_cartella
che comando gli do in php per farla passare nel db?
grazie
-
Sì questo l'ho capito, ma dato che la tabella messaggi c'hai quasi 100 campi, (test... ecc...) vuoi inserire una riga solo con $id_cartella o inserire nella stessa riga più cose?

-
ho già inserito una riga, la seconda, che si chiama id_cartelle
-
Sì, ma nella riga che inserisci che campi vai a riempire? Solo $id_cartella?


-
si un solo campo contenente il valore id_cartella
-
Allora eccoti il codice:
[php]<?php
// Dati di connessione al database
$dbhost = "localhost"; // Host del database
$dbuser = ""; // Username database (specificalo)
$dbpass = ""; // Password database, se non c'è lascia vuoto
$dbname = ""; // Nome del database (specificalo)$db = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname, $db);
$query = mysql_query("SELECT id_user, date FROM messaggi ORDER BY date DESC limit 1", $db);
while($riga = mysql_fetch_assoc($query)) {
$id_user = $riga['id_user']; }
$id_cartella = substr($id_user, -1, 1);
$cartella = "fotos/".$id_cartella;
$image_src ="fotos/" . $id_cartella . "fotos/"."1" . ".jpg";
echo "<img src="$image_src">";// Quello che vuoi inserire nel campo id_cartella
$ins = ""; // Specificalo// Qui inserisce i dati nel database
mysql_query("INSERT INTO messaggi (id_cartella) VALUES("".$ins."")", $db);// Disconnessione dal database
mysql_close($db);
?>[/php]Fammi sapere...


-
$id_cartella = substr($id_user, -1, 1);
$cartella = "fotos/".$id_cartella ;
$image_src ="fotos/" . $id_cartella . "fotos/"."50" . ".jpg";
echo "<img src="$image_src">";
$ins = "$id_cartella";
?>lo porto con la sessione alla pagina successiva:
<?php
session_start();
$_SESSION['id_cartella'] = $_INS ['id_cartella'];
?>alla terza inserisco:
<?php
session_start();
?><?php
$connessione=mysql_connect("localhost", "");
$selezione_db=mysql_select_db("guest_book", $connessione);
$id_cartella = $_SESSION['id_cartella'];
$user = $_SESSION['user'];
$gender = $_SESSION['gender'];
$year=$_SESSION['year'];
$month=$_SESSION['month'];
$day=$_SESSION['day']$query="INSERT INTO messaggi (id_user,id_cartella,user,gender,date_of_birth,country,test_arousal_photo1,test_valence_
pero' qui come la scrivo$id_cartella?
$query.=" VALUES ('$id_user','$user','$gender','$year-$month-$day','$country