Stringhe duplicate

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
con gli apici su phpmyadmin funziona, ma restituisce solo un risultato (sono 2 Horror in realta')

sshot-2.png


sshot-3.png
 

Tommy03

Utente Attivo
6 Giu 2018
616
58
28
20
Vicenza
Posta il contenuto della tabella
L'altra riga sicuro che ci sia scritto soltanto Horror? Forse intendi che non viene visualizzata perchè magari ha due generi (es. "Crime Horror"), in questo caso la query deve essere cosi:
PHP:
SELECT * FROM film_actor WHERE genre='Horror' OR genre LIKE '%Horror%' OR genre LIKE '%Horror' OR genre LIKE 'Horror%'
 

Tommy03

Utente Attivo
6 Giu 2018
616
58
28
20
Vicenza
ok, allora la query devi cambiarla cosi:
PHP:
SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
cosi mi da errore :rolleyes:

SQL:
$query = mysql_query ("SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%')";
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
PHP:
<?php
    
    require_once("connetti.php");
    

    $ok = $_GET["tag"];


$query = mysql_query ("SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'");



$result = mysql_query( $query );
if (!$result)
 die("mySQL error: ". mysql_error()); 
while( $row = mysql_fetch_object( $result ) ) : ?>

:rolleyes:


Warning: mysql_query() expects parameter 1 to be string, resource given in E:\OpenServer\domains\localhost\cinema\members\tag.php on line 34
mySQL error:

line 34

PHP:
$result = mysql_query( $query );
 

Tommy03

Utente Attivo
6 Giu 2018
616
58
28
20
Vicenza
hai già messo mysql_query, non devi metterlo un'altra volta
PHP:
$query = "SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'";



$result = mysql_query( $query );
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
:confused: ci siamo quasi

sshot-6.png

dovrebbe visualizzarmi anche questi dati

Tabella film_actor <----- (questa adesso
film_id
genre

Tabella film
movie_title
year
 

Tommy03

Utente Attivo
6 Giu 2018
616
58
28
20
Vicenza
<?php require_once("connetti.php"); $ok = $_GET["tag"]; $query = mysql_query ("SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'"); $result = mysql_query( $query ); if (!$result) die("mySQL error: ". mysql_error()); while( $row = mysql_fetch_object( $result ) ) : ?>
non hai postato il codice che c'è dopo...
Se vuoi visualizzarli in tabella, aggiungi questo dopo l'inizio del while:
PHP:
<tr>
<td><?php echo $row->film_id;?></td>
<td><?php echo $row->genre;?></td>
</tr>
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
ho fatto cosi ma visualizzo solo genre :rolleyes:

PHP:
<body>

<table>

<?php
   
    require_once("connetti.php");
   

    $ok = $_GET["tag"];




$query = "SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'";


$result = mysql_query( $query );

if (!$result)
die("mySQL error: ". mysql_error());
while( $row = mysql_fetch_object( $result ) ) : ?>



<tr>
   
<td><a href="film.php?id=<?php echo $row->film_id; ?>"></a>   // nella tabella film_actor

<td><?php echo $row->genre; ?></td>    // nella tabella film_actor

<td><?php echo $row->movie_title; ?></td>  // nella tabella film

<td><?php echo $row->year; ?></td>          // nella tabella film

</tr>


<? endwhile; ?>

</table>

</body>
 

Tommy03

Utente Attivo
6 Giu 2018
616
58
28
20
Vicenza
Sembra che ci sia tipo un problema di apici, cambia cosi:
PHP:
<?php
   
require_once("connetti.php");


$ok = $_GET["tag"];




$query = "SELECT * FROM film_actor WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'";


$result = mysql_query( $query );

if (!$result)
die("mySQL error: ". mysql_error());
while( $row = mysql_fetch_object( $result ) ) : ?>


<?php $films = $row->film_id;?>
<tr>
    
<td><?php echo "<a href='film.php?id=$films'></a>";?></td>

<td><?php echo $row->genre; ?></td>

</tr>


<? endwhile; ?>

</table>

</body>
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
inserito INNER JOIN nella query, adesso ok

per qualche strano motivo non visualizzo il film_id :rolleyes:


sshot-7.png


PHP:
<?php
    
    require_once("connetti.php");
    

    $ok = $_GET["tag"];




$query = "SELECT * FROM film_actor
INNER JOIN film ON film_actor.film_id = film.film_id
INNER JOIN actor ON film_actor.actor_id = actor.actor_id
WHERE genre='$ok' OR genre LIKE '%$ok%' OR genre LIKE '%$ok' OR genre LIKE '$ok%'";


$result = mysql_query( $query );

if (!$result)
 die("mySQL error: ". mysql_error()); 
while( $row = mysql_fetch_object( $result ) ) : ?> 



<tr>
  
<td><a href="film.php?id=<?php echo $row->film_id; ?>"></a> 

<td><?php echo $row->movie_title; ?></td>

<td><?php echo $row->year; ?></td>

<td><?php echo $row->genre; ?></td>           

</tr>


<? endwhile; ?>
 

Tommy03

Utente Attivo
6 Giu 2018
616
58
28
20
Vicenza
Ah sorry mi ero dimenticato...
Dentro al link metrici il film id altrimenti è normale che non visualizza niente
PHP:
<a href=...><?php echo $row->film_id;?></a>
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
PHP:
echo "<a href='film_tags.php?tag=$ok'>$ok &nbsp;</a> ";

con questo link e la query prelevo tutti i film del tag,
e se volessi aggiungere l'opzione di visualizzarmi tutti film del tag ma solo dell'attore? :rolleyes:

questo e per l'id attore

PHP:
$actor_id = $_GET['id'];

e nella query cosa aggiungere? :rolleyes:
 
Discussioni simili
Autore Titolo Forum Risposte Data
MarcoGrazia Operatore IN e stringhe CSV PHP 3
F confrontare due stringhe "numeriche" PHP 7
R Tradurre stringhe con php e google translator PHP 4
A Cercare un carattere uguale in due stringhe Java 5
P [PHP] Inserire stringhe in input(text),memorizzarle e stamparle in file successivo PHP 0
E [PHP] confrontare stringhe importate da csv PHP 19
M [PHP] Stringhe con accento nel POST PHP 3
M [java] esercizio lunghezza array di stringhe Java 0
K [WordPress] editare stringhe di deafault WordPress 0
S [Javascript] [HTML] creare stringhe di riferimento da riutilizzare Javascript 5
B [Java] Stringhe binarie Java 0
venomina [MySQL] Stringhe vuote MySQL 0
E [PHP] Operazioni di confronto su stringhe PHP 26
G [PHP] Operazioni sulle stringhe PHP 2
D [Problema] Comparare stringhe Sviluppo app per Android 0
S stringhe con caratteri speciali PHP 3
A Problema con stringhe e numeri interi PHP 2
M Stringhe con caratteri non codificati (es. �) PHP 1
xone Filtrare e ripulire stringhe in input PHP 1
F Controllo tra due stringhe jQuery 5
K formattazione stringhe Javascript 1
K alcuni chiarimenti sul metodo di ricerca nelle stringhe o array Javascript 1
K problema di sintassi con le stringhe PHP 5
F spazi stringhe PHP 3
N Confrontare due Stringhe PHP 2
S Stringhe: confrontare immissione con stringa d'esempio e costruire stringhe da più campi PHP 10
P Escludere stringhe contenute nei record da una select MySQL 3
M Estrapolare stringhe da una funzione PHP 7
M Dividere Stringhe per MySQL PHP 6
G Confrontare due stringhe PHP 11
F confrontare due stringhe c Programmazione 0
N Modifica valori stringhe di un altro file PHP 7
SolidSnake4 stringhe PHP 7
F programma con le stringhe in c!! Programmazione 0
N [PHP/MySQL] Problema inserimento stringhe ' or ', ' and ' PHP 2
L Problema concatenzione stringhe PHP 2
P Sostituzione stringhe sulla base di una tabella di conversione MySQL 2
catellostefano stringhe strane nell'header di template joomla Joomla 4
N variabili, stringhe e valori Javascript 4
A Confrontare 2 stringhe in JScript Classic ASP 0
A stringhe Classic ASP 2
F query con stringhe doppie Classic ASP 2
G Problema con le stringhe PHP 3
B concatenare stringhe nel document Javascript 1
S Php - Sostituzione Stringhe PHP 1
P Problema con apici nelle stringhe [era:Cambiare grandezza carattere con JavaScript] Javascript 3
F stringhe: sicurezza PHP 7
A confronto tra stringhe complesse, come fare???? PHP 1
M URGENTE: ORDINAMENTO LESSICOGRAFICO STRINGHE CON MERGESORT ricorsivo IN C (non C++) C/C++ 1
T Concatenazione stringhe Classic ASP 1

Discussioni simili