Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
i was woundering if php can be used to make a javascript statement (ie an array) pulled from a .txt document
like this example code here
within members.phpCode: Select all
<script language="JavaScript"><!--
function makeItem(date,user,loc,web) {
this.date=date;
this.user=user;
this.loc=loc;
this.web=web;
return this;
}
theItem = new Array();
var b = -1
<?php
$file = "members.txt";
if (fopen($file, "r")) {
$fil = "members.txt";
$fo = fopen ($fil, "r");
$con = fread ($fo,filesize ($fil));
fclose ($fo);
echo "$con";
} else {
echo "<h3>Sorry there was an error please contact us <h3>";
}
?>
</script>later in members.php
Code: Select all
<script language="JavaScript"><!--
Text = '';
for (i = 0, n=theItem.length;i<n;i++) {
var cd = '';
var cd = theItem[i].date;
var cu = '';
var cu = theItem[i].user;
var cl = '';
var cl = theItem[i].loc;
var cw = '';
var cw = theItem[i].web;
if ((cl == null) || (cl == '')) {
var cl = ' ';
}
if ((cw == null) || (cw == '')) {
var cw = ' ';
}
if ((cd == null) || (cd == '')) {
var cd = ' ';
}
if ((cu == null) || (cu == '')) {
i++;
}
else {
Text += '<tr><td><center><table width="100%" border="1" cellpadding="0" cellspacing="0"><td width="10%">' + cd + '<td width="20%">' + cu + '<td width="20%">' + cl + '<td width="50%">' + cw + '</table></center>';
}}
Text += '';
document.write(Text);
//--></script>
Code: Select all
theItem[(b=b+1)] = new makeItem('6-3-07','Jimmy','LA','');
theItem[(b=b+1)] = new makeItem('6-3-07','juaco','panama','');is the above even possible if not how would i do something like this without a database
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]