Salta al contenuto
  • CATEGORIES
  • La Community Connect.gt
  • Presentati alla Community
  • News Ufficiali da Connect.gt
  • Internet News
  • A Scuola Di
  • Digital Marketing
  • Intelligenza Artificiale
  • SEO & GEO
  • Web Marketing e Content
  • Google Analytics e Web Analytics
  • Google Ads & Advertising
  • YouTube
  • TikTok, Instagram e altri Social
  • Google Adsense, Affiliazioni e Guadagno
  • E-Commerce
  • Coding e Sistemistica
  • Help Center: consigli per il tuo progetto
  • Hosting e Cloud
  • Coding
  • CMS & Piattaforme Self-Hosted
  • Annunci e Collaborazioni
  • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
  • Collaborazioni WEB e Lavoro: offro e cerco
  • Impresa, Fisco e Leggi
  • Consulenza Legale e Professioni Web
  • Consulenza Fiscale, Imprese, Startup e P.Iva
  • Gli Off Topic
  • PC, Smartphone e altri Hardware
  • Tutti i Software
  • GT Fetish Cafè
  • Discussioni
  • 0 Non letti 0
  • Recenti
  • Hashtag
  • Popolare
  • Utenti
  • Privacy
  • Termini e condizioni
  • © 2026 Search On Media Group S.r.l.
Collassa
Connect.gt
Il network Search On
Connect.gt WMF AI Festival Accademia Advanced SEO Tool AgentCy Social Media Strategies Search Tech
Registrati Accedi
Connect.gt
Stream Interest Categorie Hashtag
  1. La community italiana di SEO, marketing digitale e AI
  2. Categorie
  3. Coding e Sistemistica
  4. Coding
  5. Formattazione testo

Formattazione testo

Pianificato Fissato Bloccato Spostato Coding
2 Post 2 Autori 797 Visualizzazioni 1 Seguito
  • Da Vecchi a Nuovi
  • Da Nuovi a Vecchi
  • Più Voti
Rispondi
  • Risposta alla discussione
Effettua l'accesso per rispondere
Questa discussione è stata eliminata. Solo gli utenti con diritti di gestione possono vederla.
  • S
    S
    spiderpaolo70
    scritto su ultima modifica di
    User Newbie 0
    #1
    Formattazione testo

    Salve a tutti,
    premetto che sono alle prime armi con php e mysql.
    Ho un problema che mi fa impazzire, dopo mille peripezie sono riuscito a fare un progettino flash-php-mysql, spulciando e modificando script quà e là.
    Ho fatto una galleria dinamica in flash che pesca dati da mysql attraverso php.
    Sono riuscito ad aggiungere dati che volevo visualizzare e a toglierne altri che non mi servivano e questo è già stato per me un bel banco di prova, ma almeno ho cominciato ad apprezzare il binomio php-mysql e a raccapezzarmici:?
    Per la parte flash tutto funziona a meraviglia, anche il pannello di amministrazione funge, però ho un grosso problema con la formattazione dei testi:x
    In particolare il campo chiamato "comments" non so come trasformarlo in multiriga (text area anzichè input type e come renderlo hidden, chiaramente in php.
    Quando vado a modificare la tabella da mysql in flash mi visualizza il testo formattato correttamente, quindi ne deduco che il file swf è a posto e idem
    la costruzione del lato mysql, ergo il problema sta nello script php del pannello di amministazione.
    Ho cercato in giro come rendere la formattazione dei testi passati attraverso php e me ne sono fatto un'idea, ma mi manca il passo precedente: ossia trasformare un input text in una textarea che accetti le preposizioni
    con ritorni a capo.
    Sono in crisi nera, questo è lo script del pannello di ammistrazione che presumo sia la fonte dei miei problemi :

    _____INIZIO SCRIPT PHP ______________

    <?php
    ////////////////////////////////////////////////////////////// DATABASE CONNECTION
    include_once("../config.php");
    ////////////////////////////////////////////////////////////// FUNCTIONS
    function splitVals($str){
    $chunks = split('^', $str);
    return $chunks;
    }
    ////////////////////////////////////////////////////////////// PAGE ACTIONS
    $pagetitle = "OFFERTE";
    $pagewidth = 770;
    $saveBtn = false;
    $headerImage = "<img src='../images/folder.close.gif' width='18' height='18' align='absmiddle' alt='' /> Root";
    // form vars
    $action = $_REQUEST['action'];
    $groupId = $_REQUEST['groupId'];
    $groupId = ($groupId=="")?0:$groupId;
    $picId = $_REQUEST['picId'];
    $id = $_REQUEST['idAll'];
    $title = $_REQUEST['titleAll'];
    $width = $_REQUEST['widthAll'];
    $height = $_REQUEST['heightAll'];
    $comments = $_REQUEST['commentsAll'];
    $prices = $_REQUEST['pricesAll'];
    $formPwd = $_REQUEST['formPwd'];

    ////// ACTIONS //////
    if ($action=='AUTH'){
    if ($formPwd == $adminPwd){
    $_SESSION['authorized'] = 'Y';
    }
    }else if ($action=='SAVE'){
    $idCol = splitVals($id);
    $titleCol = splitVals($title);
    $widthCol = splitVals($width);
    $heightCol = splitVals($height);
    $commentsCol = splitVals($comments);
    $pricesCol = splitVals($prices);

    for ($x=0; $x<count($idCol); $x++){
    //echo("X=".$titleCol[$x]);
    $updateQry = "update ".$dbTable." set title='".$titleCol[$x]."', width='".$widthCol[$x]."', height='".$heightCol[$x]."', comments='".$commentsCol[$x]."', prices='".$pricesCol[$x]."' where id=".$idCol[$x];
    $success = mysql_query($updateQry);
    }
    }else if ($action == 'DELETE'){
    $deleteQry = "delete from ".$dbTable." where id=".$picId;
    $success = mysql_query($deleteQry);
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>[<?=$pagetitle?>]</title>
    <link rel="stylesheet" type="text/css" href="../global.css" />
    <script language="JavaScript" type="text/javascript" src="../js/launchWindow.js"></script>
    <script language="JavaScript" type="text/javascript">
    <!--
    function getVals(col){
    var values = new Array();
    for (var x=0; x<col.length; x++){
    values.push(col[x].value);
    }return values;
    }
    function submitForm(action,groupId,picId){
    if (action=='SAVE'){
    document.adminForm.idAll.value = getVals(document.getElementsByName('id')).join("^");
    document.adminForm.titleAll.value = getVals(document.getElementsByName('title')).join("^");
    document.adminForm.widthAll.value = getVals(document.getElementsByName('width')).join("^");
    document.adminForm.heightAll.value = getVals(document.getElementsByName('height')).join("^");
    document.adminForm.commentsAll.value = getVals(document.getElementsByName('comments')).join("^");
    document.adminForm.pricesAll.value = getVals(document.getElementsByName('prices')).join("^");
    }else if (action=='RELOAD'){
    document.adminForm.groupId.value = groupId;
    }else if (action=='DELETE'){
    document.adminForm.picId.value = picId;
    }
    document.adminForm.action.value = action;
    document.adminForm.submit();
    }
    function delPic(picId){
    var confirmed = confirm("You are about the delete this entry.\n Are you sure you want to proceed?\n");
    if (confirmed){
    submitForm('DELETE',null,picId);
    }else{
    return void(0);
    }
    }
    //-->
    </script>
    </head>
    <body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
    <?php include("../header.php");?>
    <?
    if ($_SESSION['authorized']=='Y'){
    ?>
    <form action="index.php" name="adminForm" method="post">
    <input type="hidden" name="action" value="">
    <input type="hidden" name="groupId" value="<?=$groupId?>">
    <input type="hidden" name="idAll" value="">
    <input type="hidden" name="titleAll" value="">
    <input type="hidden" name="widthAll" value="">
    <input type="hidden" name="heightAll" value="">
    <input type="hidden" name="commentsAll" value="">
    <input type="hidden" name="pricesAll" value="">
    <input type="hidden" name="picId" value="">
    <? // get parent to show the navigate up link
    $parentQry = "SELECT * FROM ".$dbTable." WHERE ID='".$groupId."'";
    $parentResult = mysql_query($parentQry);
    if ($parentResult){
    while($pRow = mysql_fetch_array($parentResult)){
    $headerImage = "<a href="javascript:submitForm('RELOAD','".$pRow[1]."',null)" class='tabletxt2'><img src='../images/folder.open.gif' width='18' height='18' border='0' align='absmiddle' hspace='5'/> UP - ".$pRow[2]."</a>";
    }
    }
    ?>
    <table cellpadding="0" cellspacing="0" border="0" align="center" width="95%">
    <tr>
    <td align="center">

    <table cellpadding="0" cellspacing="0" class="tableHeader" border="0" width="100%">
    <tr>
    <td class="normal" width="1"><img src="images/sp.gif" width="1" height="38" alt="" /></td>
    <td class="normal tabletxt2"></td>
    </tr>
    </table>
    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
    <td width="30"> </td>
    <td>
    <table cellpadding="3" cellspacing="1" class="tableBg" border="0" width="100%">
    <?php
    $imgQry = 'SELECT * FROM '.$dbTable.' WHERE PARENT_ID='.$groupId.' ORDER BY SRC';
    $result = mysql_query($imgQry);
    // display each child
    while ($row = mysql_fetch_array($result)) {
    $rowHTML = "<tr>";
    if ($row[3]==""){
    $rowHTML .= "<td colspan='9' class='accent1'><img src='../images/folder.close.gif' width='18' height='18' hspace='3' alt='' align='absmiddle' /><a href="javascript:submitForm('RELOAD','".$row[0]."',null)" class='tabletxt2'>".$row[2]."</a>  </td>";
    $rowHTML .= "<td class='accent1' width='60' align='center'><a href="javascript:launchWindow('renamefolder.php?groupId=".$row[0]."&parentId=".$groupId."','500','200','upload','N')" class='small'>[Rename]</a></td>";
    }else{
    $saveBtn = true;
    $rowHTML .= "<td class='accent1 tabletxt1' width='60' align='right'><input type='hidden' name='id' value='".$row[0]."' />Title:</td>";
    $rowHTML .= "<td class='accent0' width='170'><input type='text' class='input' name='title' value='".str_replace(''', ''',$row[2])."'/></td>";
    $rowHTML .= "<td class='accent1 tabletxt1' width='10' align='right'>Width:</td>";
    $rowHTML .= "<td class='accent0' width='170'><input type='text' class='input' size='5' name='width' value='".$row[4]."'/></td>";
    $rowHTML .= "<td class='accent1 tabletxt1' width='10' align='right'>Height:</td>";
    $rowHTML .= "<td class='accent0' width='170'><input type='text' class='input' size='5' name='height' value='".$row[5]."'/></td>";
    $rowHTML .= "<td class='accent1 tabletxt1' width='60' align='right'>Comments:</td>";
    $rowHTML .= "<td class='accent0' width='170'><input type='text' class='input' size='30' name='comments' value='".str_replace(''', ''',$row[6])."'/></td>";
    $rowHTML .= "<td class='accent1 tabletxt1' width='60' align='right'>Prices:</td>";
    $rowHTML .= "<td class='accent0' width='170'><input type='text' class='input' size='30' name='prices' value='".str_replace(''', ''',$row[7])."'/></td>";
    $rowHTML .= "<td class='accent1' width='20'><a href='javascript:delPic("".$row[0]."")'><img src='../images/delete.icon.gif' width='18' height='18' border='0' alt='Delete Entry' /></td>";
    $rowHTML .= "<td class='accent0 tabletxt1' width='60'><img src='../".$row[3]."' class='input' width='50' height='50' /></td>";
    }
    $rowHTML .= "</tr>";
    echo($rowHTML);
    }

    ?>
    </table>
    </td>
    </tr>
    </table>

    </td>
    </tr>
    </table>
    <table cellpadding="3" cellspacing="0" border="0" width="100%">
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td align="center">
    <? if ($saveBtn){?><input type="button" class="button" onClick="submitForm('SAVE',null,null);" value="Save"/><?}?>    
    <input type="button" class="button" onClick="launchWindow('uploadimage.php?groupId=<?=$groupId?>','500','200','upload','N')" value="Upload Image"/>  
    <input type="button" class="button" onClick="launchWindow('../','700','500','preview','Y')" value="Preview"/>  
    </td>
    </tr>
    </table>
    </form>
    <?php
    }else{
    ?>
    <form action="index.php" name="adminForm" method="post">
    <table cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td class="normal" width="1%" nowrap>Password: <input type="password" name="formPwd" class="input"> <input type="submit" class="button"><input type="hidden" name="action" value="AUTH"></td>
    </tr>
    </table>
    </form>
    <?}?>
    <?php include("../footer.php");?>
    </body>
    </html>

    __FINE SCRIPT ____________

    In poche parole non so come rendere "comments" multilinea:o
    Ah dimenticavo : le variabili $row[n] rappresentano la riga del mio DB che contiene i valori.
    Lo so che mi sono spiegato da schifo ma in questo periodo sto facendo mille cose causa matrimonio e devo correre per fare qualsiasi cosa, quindi scusatemi in anticipo.
    Aspetto con ansia suggerimenti.
    Ciao

    1 Risposta Ultima Risposta
    Miglior risposta 0
    0
    • T
      T
      tifo.milan.it
      Bannato
      scritto su ultima modifica di
      User Attivo 0
      #2

      non sono sicuro di aver capito bene.. però... se cerchi un modo di far tornre a capo il testo ogni volta che vai a capo te, tipo WYSIWYG.. allora potresti usare la funzione nl2br
      e funziona cosi:
      nell'estrazione echo nl2br($row[testo]);

      1 Risposta Ultima Risposta
      Miglior risposta 0
      0

      Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.

      Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.

      Con il tuo contributo, questo post potrebbe essere ancora migliore 💗

      Registrati Accedi
      Rispondi
      • Risposta alla discussione
      Effettua l'accesso per rispondere
      • Da Vecchi a Nuovi
      • Da Nuovi a Vecchi
      • Più Voti


      • Accedi

      • Non hai un account? Registrati

      • Accedi o registrati per effettuare la ricerca.
      • Primo post
        Ultimo post
      Home Accedi Registrati
      Menu
      • CATEGORIES
      • La Community Connect.gt
      • Presentati alla Community
      • News Ufficiali da Connect.gt
      • Internet News
      • A Scuola Di
      • Digital Marketing
      • Intelligenza Artificiale
      • SEO & GEO
      • Web Marketing e Content
      • Google Analytics e Web Analytics
      • Google Ads & Advertising
      • YouTube
      • TikTok, Instagram e altri Social
      • Google Adsense, Affiliazioni e Guadagno
      • E-Commerce
      • Coding e Sistemistica
      • Help Center: consigli per il tuo progetto
      • Hosting e Cloud
      • Coding
      • CMS & Piattaforme Self-Hosted
      • Annunci e Collaborazioni
      • Annunci Vendita e Acquisto: Pubblicità, Domini, Link e altro
      • Collaborazioni WEB e Lavoro: offro e cerco
      • Impresa, Fisco e Leggi
      • Consulenza Legale e Professioni Web
      • Consulenza Fiscale, Imprese, Startup e P.Iva
      • Gli Off Topic
      • PC, Smartphone e altri Hardware
      • Tutti i Software
      • GT Fetish Cafè
      • Discussioni
      • Non letti 0
      • Recenti
      • Hashtag
      • Popolare
      • Utenti
      • Privacy
      • Termini e condizioni
      • © 2026 Search On Media Group S.r.l.