Jump to content

sjns

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sjns's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I will complete that code, hope someone can help me and I would appreciate it. Here the complete code: I have a few pages from each other to interact with page with id load, as below: inside of page process.html as follows <form action="<?php echo $send; ?>" method="post" id="choose">//data send to process.php and redirect back to ?p=process (process.html page) <!--some options here --> <a onclick="$('#choose').submit();" class="button"> <span> <?php echo $button_next;?> </span></a> </form> <?php //if ($this->options->hasChosed()) { ?> <div id="guest_details"> </div> <?php //} ?> <?php if (isset($this->session->data['guest'])) { ?> <div id="first_start"> </div> <?php } ?> <script type="text/javascript"> <!-- $('#guest_details').load('?p=guest_details'); $('#first_start').load('?p=first_start'); $('#guest_details').hide('slow'); $('#first_start').show('slow') --> </Script> inside of page guest_details.html as follows <form action="<?php echo $send; ?>" method="POST" id="guest">//data send to guest_details.php and redirect back to ?p=process (process.html page) <!-- Some cell here --> <a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_next;?> </span></a> </Form> inside of page first_start.html as follows <form action="<?php echo $send; ?>" method="POST" id="_start">/data send to first_start.php and redirect back to ?p=process (process.html page) <!-- Some cell here --> <a href="<?php echo str_replace($edit_guest_details); ?>" class="button"> <span> <?php echo $edit_guest;?> </span></a> <a onclick="$('#_start').submit();" class="button" id="f_start"> <span> <?php echo $button_next;?> </span></a> </Form> situations: page guest_details.html and first_start.html load inside process.html with using load('?p=guest_details') and load('?p=first_start') by default guest_details.html is showing and first_start.html is hiding Goals: when guest_details.html form submited by click <a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_next;?> </span></a> then hide the page guest_details.html and show first_start.html now at first_start.htm page guest_details.html should be hide even so page refresh(f5), but when button <a href="<?php echo $edit_guest_details; ?>" class="button"> <span> <?php echo $edit_guest;?> </span></a> clicked then guest_details.html show again Looking for some pointers, Thanks in Advance
  2. I have a few pages from each other to interact with page with id load, as below: inside process.html <div id="guest_details"> </div> <div id="first_start"> </div> <script> <! - $('#guest_details').load('?p=guest_details.html'); $('#first_start').load('?p=first_start.html') $('#guest_details').hide('slow'); $('#first_start').SlideUp('slow') -> </Script> inside guest_details.html <form action="guest_details.php" <form method="POST" id="guest"> <!-- Some cell here --> <a onclick="$('#guest').submit();" class="button" id="first_start"> <span> <?php echo $button_submit;?> </span> </a> </Form> That I want is when the submit button is clicked then: 1. data sent to guest_details.php 2. If the data has been sent then hide <div id="guest_details"> </div> 3. showing the <div show id="first_start"> </div> but when I make it like the above, that not work, Could someone give a clue how to correct? Thanks a lot
  3. Thanks for your reply. i mean not work properly because the error message appear when i tested in MS. Frontpage said: Line: 24 Char:9 Error: Object doesn't support this property or method code: 0 any Idea to make this run?
  4. Hi, If someone here is willing to help me I would really appreciate the function removeInput() of javascript at below not work properly, what i should do? <script language="javascript"> fields = 0; function addInput() { if (fields != 10) { var htmlText = "<input type='text' name='friends[]' value='' size='auto' maxlength='45' /><br />"; var newElement = document.createElement('div'); newElement.id = 'addfriend'; newElement.innerHTML = htmlText; var fieldsArea = document.getElementById('addfriend'); fieldsArea.appendChild(newElement); fields += 1; } else { alert("Only 10 friends allowed."); document.form.add.disabled=true; } } //field = 0; function removeInput() { //======= doesn't work =========== var div = document.getElementById('addfriend'); var lastElement = document.removeElement('div'); lastElement.id = 'addfriend'; if (lastElement > 2) div.Element(lastElement - 1); } </script> Thanks a lots
  5. Hi, If someone here is willing to help me I would really appreciate how to limit the addition of columns in the following html code, let say only up to 5 only? Code: <script type="text/javascript"><!-- function addFriend() { var tbl = document.getElementById('my_friends'); var iteration = tbl.tBodies[0].rows.length; newRow = tbl.tBodies[0].insertRow(-1); var newCell = newRow.insertCell(0); newCell.innerHTML = '<?php echo $entry_friend; ?>'; var newCell1 = newRow.insertCell(1); var el = document.createElement('input'); el.type = 'text'; el.name = 'friends[]'; el.size = 30; el.maxlength = 45; newCell1.appendChild(el); // if (newCell > 2) tbl.addCell(newCell + 1); } function removeFriend() { var tbl = document.getElementById('my_friends'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } //--></script> Thanks in advance
  6. Hi Guys, I have stuck with my problem and i am nothing to php, i already posted this to another php script forum, but haven't solve, so i wondering if anyone here help me and many thanks. this is all about game scores from .xml file inside the xml file itself as: <gesmes:Envelope> <gesmes:subject>Reference Scores</gesmes:subject> - <gesmes:Sender> <gesmes:name>Game Information Scores</gesmes:name> </gesmes:Sender> - <Cube> - <Cube time="2010-10-13"> <Cube scores="GameA1" value="1.5803"/> <Cube scores="GameA2" value="21.35"/> ............etc <Cube scores="GameA15" value="135"/> </Cube> </Cube> </gesmes:Envelope> then i got php script that can save all data of .xml above to mysql, look like <?php class Scores_Converter { var $xml_file = "http://192.168.1.112/gamescores/scores-daily.xml"; var $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_table; var $scores_values = array(); //Load convertion scores function Scores_Converter($host,$user,$pass,$db,$tb) { $this->mysql_host = $host; $this->mysql_user = $user; $this->mysql_pass = $pass; $this->mysql_db = $db; $this->mysql_table = $tb; $this->checkLastUpdated(); $conn = mysql_connect($this->mysql_host,$this->mysql_user,$this->mysql_pass); $rs = mysql_select_db($this->mysql_db,$conn); $sql = "SELECT * FROM ".$this->mysql_table; $rs = mysql_query($sql,$conn); while($row = mysql_fetch_array($rs)) { $this->scores_values[$row['scores']] = $row['value']; } } /* Perform the actual conversion, defaults to 1.00 GameA1 to GameA3 */ function convert($amount=1,$from="GameA1",$to="GameA3",$decimals=2) { return(number_format(($amount/$this->scores_values[$from])*$this->scores_values[$to],$decimals)); } /* Check to see how long since the data was last updated */ function checkLastUpdated() { $conn = mysql_connect($this->mysql_host,$this->mysql_user,$this->mysql_pass); $rs = mysql_select_db($this->mysql_db,$conn); $sql = "SHOW TABLE STATUS FROM ".$this->mysql_db." LIKE '".$this->mysql_table."'"; $rs = mysql_query($sql,$conn); if(mysql_num_rows($rs) == 0 ) { $this->createTable(); } else { $row = mysql_fetch_array($rs); if(time() > (strtotime($row["Update_time"])+(12*60*60)) ) { $this->downloadValueScores(); } } } /* Download xml file, extract exchange values and store values in database */ function downloadValueScores() { $scores_domain = substr($this->xml_file,0,strpos($this->xml_file,"/")); $scores_file = substr($this->xml_file,strpos($this->xml_file,"/")); $fp = @fsockopen($scores_domain, 80, $errno, $errstr, 10); if($fp) { $out = "GET ".$scores_file." HTTP/1.1\r\n"; $out .= "Host: ".$scores_domain."\r\n"; $out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1. Gecko/20051111 Firefox/1.5\r\n"; $out .= "Connection: Close\r\n\r\n"; fwrite($fp, $out); while (!feof($fp)) { $buffer .= fgets($fp, 128); } fclose($fp); $pattern = "{<Cube\s*scores='(\w*)'\s*value='([\d\.]*)'/>}is"; preg_match_all($pattern,$buffer,$xml_values); array_shift($xml_values); for($i=0;$i<count($xml_values[0]);$i++) { $exchange_value[$xml_values[0][$i]] = $xml_values[1][$i]; } $conn = mysql_connect($this->mysql_host,$this->mysql_user,$this->mysql_pass); $rs = mysql_select_db($this->mysql_db,$conn); foreach($exchange_value as $scores=>$value) { if((is_numeric($value)) && ($value != 0)) { $sql = "SELECT * FROM ".$this->mysql_table." WHERE scores='".$scores."'"; $rs = mysql_query($sql,$conn) or die(mysql_error()); if(mysql_num_rows($rs) > 0) { $sql = "UPDATE ".$this->mysql_table." SET value=".$value." WHERE scores='".$scores."'"; } else { $sql = "INSERT INTO ".$this->mysql_table." VALUES('".$scores."',".$value.")"; } $rs = mysql_query($sql,$conn) or die(mysql_error()); } } } } /* Create the scores table */ function createTable() { $conn = mysql_connect($this->mysql_host,$this->mysql_user,$this->mysql_pass); $rs = mysql_select_db($this->mysql_db,$conn); $sql = "CREATE TABLE ".$this->mysql_table." ( scores char(3) NOT NULL default '', value float NOT NULL default '0', PRIMARY KEY(scores) ) ENGINE=MyISAM"; $rs = mysql_query($sql,$conn) or die(mysql_error()); $sql = "INSERT INTO ".$this->mysql_table." VALUES('GameA0',1)"; $rs = mysql_query($sql,$conn) or die(mysql_error()); $this->downloadValueScores(); } } ?> but that php script above just create table of mysql below CREATE TABLE IF NOT EXISTS `scrore_table` ( `scores` char(3) NOT NULL default '', `value` float NOT NULL default '0', PRIMARY KEY (`scores`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `scrore_table` (`scores`, `value`) VALUES ('GameA0', 1), ('GameA1', 1.5651), ......etc ('GameA15', 95.572); while of my existing database table look like: CREATE TABLE IF NOT EXISTS `scrore_table` ( `scrore_id` int(11) NOT NULL auto_increment, `scrore_title` varchar(32) collate utf8_bin NOT NULL default '', `scores` varchar(3) collate utf8_bin NOT NULL default '', `decimal_place` char(1) collate utf8_bin NOT NULL, `value` float(15, NOT NULL, `date_updated` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`currency_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; ; INSERT INTO `scrore_table` (`scrore_id`, `scrore_title`, `scores`, `decimal_place`, `value`, `date_updated`) VALUES (1, 'Game Class A0', 'GameA0', '2', 1.00000000, '2010-04-06 22:00:54'), (2, 'Game Class A1', 'GameA1', '2', 1.52600002, '2010-04-06 22:00:54'), ..............................etc (14, 'Game Class A15', 'GameA15', '2', 1.13999999, '2010-04-06 22:00:54'); as i said i newbie to php then i dont know how to modify the php code above able to automatically create the table and insert/update new fields e.g. scrore_id, scrore_title,decimal_place, date_updated also all values to my existing database i looking for some helps and thanks in advance..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.