|
| HOMEPAGE | INDICE FORUM | REGOLAMENTO | ::. | NEI PREFERITI | .:: | RSS Forum | RSS News | NEWS web | NEWS software | |
| PUBBLICITA' | | | ARTICOLI | WIN XP | VISTA | WIN 7 | REGISTRI | SOFTWARE | MANUALI | RECENSIONI | LINUX | HUMOR | HARDWARE | DOWNLOAD | | | CERCA nel FORUM » | |
06-03-2014, 17.13.26 | #1 |
Newbie
Registrato: 08-04-2008
Messaggi: 29
|
php limitare lunghezza del testo in tabella Mysql
il mio problema è quello di limitare una descrizione in una tabella Mysql. Ho provato lo script in un testo normale fuori tabella e funziona regolarmente ma non riesco ad ottenere lo stesso risultato in un campo della tabella Mysql. Compare soltanto un trattino verde. Vorrei anche poter intervenire sulla dimensione del carattere. Allego una parte della pagina. ..... <table class="righealterne"> <thead><tr> <th>rif</th> <th>foto</th> <th>comune / zona</th> <th>descrizione</th> <th>mq</th> <th>prezzo/canone</th> <th>dettaglio</th> </tr></thead> <?php include("config.inc.php"); // parametri del database $db = mysql_connect ($db_host, $db_user, $db_pass); if($db = FALSE) die ("errore nella connessione"); mysql_select_db ($db_name)or die("errore nella selezione del database"); $query = "SELECT * FROM $db_tab WHERE vetrina='si' AND uso='co' ORDER BY rif DESC" ; $result = mysql_query ($query) or die("nessun immobile con questi requisiti"); $numero_caratteri = 10; $stringa_in_input = '$row[des_scheda]'; if(strlen(trim($stringa_in_input))>$numero_caratte ri) { $testo = substr($stringa_in_input,0,strpos($stringa_in_inpu t,' ',$numero_caratteri)).'...'; } else { $testo = $stringa_in_input; } $testo='$row[des_scheda]'; //conto il numero di occorrenze trovate nel db $numrows = mysql_num_rows($result); //se il database e' vuoto lo stampo a video if ($numrows==0){ print"<b><font size=2> <P><FONT SIZE=2><B>Al momento non abbiamo immobili con questi requisiti.<BR>Contattateci per avere notizie su eventuali acquisizioni non ancora pubblicate.</B></FONT></P> </font></b><br><br> <br><br>"; } //Se invece trovo delle occorrenze... else { while ($row = mysql_fetch_array ($result)) {echo "<tr><td>$row[rif]</td>"; echo '<td align="center"><a href="scheda_dettaglio.php?rif='.$row['rif'].'" target=_blank alt="scheda"><img src="icona.php?rif='.$row['rif'].'"alt="scheda"></a></td>'; echo "<td>$row[comune]</td>"; echo "<td >$row[des_tabella]<br/>"; $testo = '$row[des_scheda]'; echo "<span id='prova'>$testo</span></td>"; echo "<td style=\"width: 50px\" align=\"center\">$row[mq]</td>"; echo '<td>'.number_format($row['prezzo'],0,',','.').'</td>'; echo '<td><a href="scheda_dettaglio.php?rif='.$row['rif'].'" target=_blank>scheda</a></td></tr>'; } } mysql_free_result ($result); ?> </table> ..... Qualche anima buona mi può aiutare? Grazie |
08-03-2014, 16.42.34 | #2 |
Newbie
Registrato: 08-04-2008
Messaggi: 29
|
Rif: php limitare lunghezza del testo in tabella Mysql
Dopo innumerevoli tentativi ho risolto il problema spostando lo script all'interno della tabella, se può essere utile a qualcuno inserisco un tratto di codice;
Codice:
........ while ($row = mysql_fetch_array ($result)) { echo "<tr><td>$row[rif]</td>"; $numero_caratteri = 35; $stringa_in_input = $row['des_scheda']; if(strlen(trim($stringa_in_input))>$numero_caratteri) { $testo = substr($stringa_in_input,0,strpos($stringa_in_input,' ',$numero_caratteri)).'...'; } else { $testo = $stringa_in_input; } echo "<span id='prova'>$testo</span></td>"; echo "<td style=\"width: 50px\" align=\"center\">$row[mq]</td>"; echo '<td>'.number_format($row['prezzo'],0,',','.').'</td>'; echo '<td><a href="scheda_dettaglio.php?rif='.$row['rif'].'" target=_blank>scheda</a></td></tr>'; } } mysql_free_result ($result); ?> </table> |
08-03-2014, 19.01.32 | #3 |
Gold Member
Top Poster
Registrato: 06-07-2006
Loc.: Brindisi
Messaggi: 10.111
|
Rif: php limitare lunghezza del testo in tabella Mysql
Bene eisenblu, sicuramente sarà utile a qualcuno
___________________________________
Dove l'ho sentita ? www.plagimusicali.net English Amiga Board Amiganews.it AfA One AROS x86 AROS 68k |
Utenti attualmente attivi che stanno leggendo questa discussione: 1 (0 utenti e 1 ospiti) | |
Strumenti discussione | |
|
|
Discussioni simili | ||||
Discussione | Autore discussione | Forum | Risposte | Ultimo messaggio |
MySQL PHP Generator 12.8.0.12 | WinTricks | News SOFTWARE | 0 | 01-09-2013 02.14.59 |
Fedora15 mysql, e php, problema di configurazione AUTORISOLTO | Redentore | Programmazione | 0 | 17-10-2011 16.46.19 |
Excel evidenziare caselle (per veri esperti) | Zenit | Office suite | 7 | 05-01-2006 12.24.43 |
[Mysql] Php non vede Mysql [OK] | espiritos | Programmazione | 17 | 01-12-2005 21.59.52 |
trasformare una tabella in testo | LUCAB | Office suite | 5 | 17-09-2004 10.40.42 |