• Home
  • Forum
  • Fare Web
  • PHP

Stringhe duplicate

  • Creatore Discussione Creatore Discussione Alex_70
  • Data di inizio Data di inizio 15 Lug 2020
  • Tag Tag
    php string
Prec.
  • 1
  • 2
Primo Prec. 2 di 2

Alex_70

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



 

Tommy03

Utente Attivo
6 Giu 2018
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #22
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%'
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 15 Lug 2020
  • #23
si, perche' ha 2 generi

 

Tommy03

Utente Attivo
6 Giu 2018
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #24
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
  • 15 Lug 2020
  • #25
cosi mi da errore

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

Tommy03

Utente Attivo
6 Giu 2018
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #26
Alex_70 ha scritto:
LIKE '$ok%')";
Clicca per allargare...
sposta i doppi apici prima della parentesi...
PHP:
$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
  • 15 Lug 2020
  • #27
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 ) ) : ?>




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
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #28
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
  • 15 Lug 2020
  • #29
ci siamo quasi


dovrebbe visualizzarmi anche questi dati

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

Tabella film
movie_title
year
 

Tommy03

Utente Attivo
6 Giu 2018
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #30
Alex_70 ha scritto:
<?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 ) ) : ?>
Clicca per allargare...
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
  • 15 Lug 2020
  • #31
ho fatto cosi ma visualizzo solo genre

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
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #32
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
  • 15 Lug 2020
  • #33
inserito INNER JOIN nella query, adesso ok

per qualche strano motivo non visualizzo il film_id




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
614
58
28
21
Vicenza
  • 15 Lug 2020
  • #34
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
  • 15 Lug 2020
  • #35
sembra che abbiamo risolto

grazie Tommy


 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 15 Lug 2020
  • #36


 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 15 Lug 2020
  • #37
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?

questo e per l'id attore

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

e nella query cosa aggiungere?
 
Prec.
  • 1
  • 2
Primo Prec. 2 di 2
Devi accedere o registrarti per poter rispondere.

Discussioni simili

Operatore IN e stringhe CSV
  • MarcoGrazia
  • 21 Set 2022
  • PHP
Risposte
3
Visite
1K
PHP 30 Set 2022
MarcoGrazia
F
confrontare due stringhe "numeriche"
  • francescoITA
  • 25 Nov 2020
  • PHP
Risposte
7
Visite
2K
PHP 26 Nov 2020
francescoITA
F
R
Tradurre stringhe con php e google translator
  • Roberto_V
  • 6 Lug 2020
  • PHP
Risposte
4
Visite
3K
PHP 7 Lug 2020
Alex_70
A
  • Bloccata
Cercare un carattere uguale in due stringhe
  • Andre_Flav
  • 1 Apr 2020
  • Java
Risposte
5
Visite
2K
Java 2 Apr 2020
Max 1
P
[PHP] Inserire stringhe in input(text),memorizzarle e stamparle in file successivo
  • pizzettino
  • 3 Apr 2019
  • PHP
Risposte
0
Visite
3K
PHP 3 Apr 2019
pizzettino
P
E
  • Bloccata
[PHP] confrontare stringhe importate da csv
  • evilsait83
  • 25 Feb 2019
  • PHP
Risposte
19
Visite
3K
PHP 3 Mar 2019
Max 1
M
[PHP] Stringhe con accento nel POST
  • Marcom149
  • 6 Feb 2019
  • PHP
Risposte
3
Visite
2K
PHP 7 Feb 2019
kastaldi
K
M
[java] esercizio lunghezza array di stringhe
  • ManuelaP
  • 22 Ago 2018
  • Java
Risposte
0
Visite
3K
Java 22 Ago 2018
ManuelaP
M
K
[WordPress] editare stringhe di deafault
  • keyboardistdenny
  • 3 Giu 2018
  • WordPress
Risposte
0
Visite
948
WordPress 3 Giu 2018
keyboardistdenny
K
S
[Javascript] [HTML] creare stringhe di riferimento da riutilizzare
  • simone battistutta
  • 20 Mag 2018
  • Javascript
Risposte
5
Visite
1K
Javascript 21 Mag 2018
Max 1
B
[Java] Stringhe binarie
  • Boogyeman
  • 4 Feb 2018
  • Java
Risposte
0
Visite
3K
Java 4 Feb 2018
Boogyeman
B
[MySQL] Stringhe vuote
  • venomina
  • 2 Mag 2017
  • MySQL
Risposte
0
Visite
1K
MySQL 2 Mag 2017
venomina
E
[PHP] Operazioni di confronto su stringhe
  • enzogar
  • 17 Gen 2017
  • PHP
  • 2
Risposte
26
Visite
10K
PHP 24 Gen 2017
enzogar
E
G
[PHP] Operazioni sulle stringhe
  • Gian06
  • 11 Gen 2017
  • PHP
Risposte
2
Visite
2K
PHP 12 Gen 2017
Gian06
G
D
[Problema] Comparare stringhe
  • Dark-Vex
  • 23 Ago 2016
  • Sviluppo app per Android
Risposte
0
Visite
1K
Sviluppo app per Android 23 Ago 2016
Dark-Vex
D
S
stringhe con caratteri speciali
  • Santino Bellinvia
  • 11 Dic 2015
  • PHP
Risposte
3
Visite
2K
PHP 17 Dic 2015
filomeni
A
Problema con stringhe e numeri interi
  • automation64
  • 30 Nov 2015
  • PHP
Risposte
2
Visite
1K
PHP 30 Nov 2015
borgo italia
M
Stringhe con caratteri non codificati (es. �)
  • Maures
  • 6 Nov 2015
  • PHP
Risposte
1
Visite
2K
PHP 6 Nov 2015
borgo italia
Filtrare e ripulire stringhe in input
  • xone
  • 21 Gen 2015
  • PHP
Risposte
1
Visite
1K
PHP 22 Gen 2015
filomeni
F
Controllo tra due stringhe
  • Fabio90
  • 27 Nov 2014
  • jQuery
Risposte
5
Visite
2K
jQuery 15 Dic 2014
Fabio90
F
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • PHP
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?