1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

data not showing in multi line

Discussion in 'PHP' started by hulkrana, Jan 27, 2008.

  1. #1
    hello frds ,
    my problem is that i need to fetch data from table in multiple lines and thats done with php inserted in js.
    data is gng to be fetched but now showing in multiple rows.code is presented here
    function update()
    {
    frm2.unt.value=frm2.box1.options[frm2.box1.selectedIndex].text;
    frm1.untcd.value=frm2.box1.value;
    frm1.vch_cd.value=frm2.box1.options[frm2.box1.selectedIndex].text;
    //alert(frm2.unt.value);
    frm2.submit();
    //alert(frm2.unt.value);
    rw=document.getElementById('tbls1').rows.length;
    var x=document.getElementById('tbls1').insertRow(rw);
    document.getElementById('tbls1').rules="rows";
    var w=x.insertCell(0);
    var y=x.insertCell(1);
    var z=x.insertCell(2);
    var a=x.insertCell(3);
    var p=x.insertCell(4);

    var h=x.insertCell(5);
    w.width="2%";
    y.width="30%";
    z.width="40%";
    p.width="5%";
    w.align="right";
    y.align="left";
    z.align="left";
    a.align="left";
    p.align="right";
    //alert(frm2.unt.value);
    <?php
    $con = pg_connect("dbname=fa user=postgres");
    $rt="select a.led_name,b.subled_name,c.* from t_fa_voucher c inner join t_fa_ledger a on a.led_id=c.ledg_id inner join t_fa_subledger b on c.subledg_id=b.subled_id and vch_no='".$_POST['unt']."'";
    $rt1=pg_query($con,$rt);
    if($rt1)
    {
    while($rt2=pg_fetch_array($rt1))
    { $pp=pg_num_rows($rt1);

    ?>
    w.innerHTML="<?php echo $rt2[7]; ?>";
    h.innerHTML="<?php echo "sonu".$pp; ?>";
    y.innerHTML="<?php echo $rt2[0];?>";
    z.innerHTML="<?php echo $rt2[1];?>";
    a.innerHTML="<?php echo $rt2[10];?>";

    <?php
    }
    }
    ?>
    alert(h.innerHTML);
    }

    plz tel me how to perform this

    thx
     
    hulkrana, Jan 27, 2008 IP
  2. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't understand your problem. What's wrong with this code? What exactly does it do, and what should it to do?
     
    CreativeClans, Jan 28, 2008 IP
  3. harsh789

    harsh789 Member

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    You need to convert multiline php string to single line before you assing it to javascript variable. for example change following line of code

    w.innerHTML="<?php echo $rt2[7]; ?>";
    PHP:
    with this

    w.innerHTML="<? echo str_replace("\r\n","",nl2br(addslashes($rt2[7]))); ?>";
    PHP:
     
    harsh789, Jan 28, 2008 IP