Credit Cards - Loans - Mortgage Loans - Xbox Games - Super Mario Games

PDA

View Full Version : data not showing in multi line


hulkrana
Jan 28th 2008, 12:13 am
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

CreativeClans
Jan 28th 2008, 3:31 am
I don't understand your problem. What's wrong with this code? What exactly does it do, and what should it to do?

harsh789
Jan 28th 2008, 3:55 am
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]; ?>";

with this

w.innerHTML="<? echo str_replace("\r\n","",nl2br(addslashes($rt2[7]))); ?>";