
xhelle
Members-
Posts
22 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
xhelle's Achievements

Member (2/5)
0
Reputation
-
Hi to all, I just need your help here... I'm just a newbie in ajax/javascript code... My problem is I need to update my database using a checkbox(onClick function) to validate. I try to alert all value I pass down but nothing happen in php... My query is correct because I try it using hard cord... I dont know were the problem here... hope someone here can help me... thanks I'll post the code here... [ajax code] function trim(stringToTrim){ return stringToTrim.replace(/^\s+|\s+$/g,""); } function validate(cb){ if(eval("document.myform.chbox[" + cb + "].checked")==true){ for(j = 0; j < 500; j++){ if(eval("document.myform.chbox[" + j + "].checked") == true){ document.myform.chbox[j].checked = false; if(j == cb){ document.myform.chbox[j].checked = true; var a1 = document.getElementById('lbG' + j).innerHTML; var a2 = document.getElementById('lbA' + j).innerHTML; var a3 = document.getElementById('lbE' + j).innerHTML; updateCustomerTable('1',a1,a2,a3); } } } } } var xmlhttpUpdate function updateCustomerTable(a0,a1,a2,a3){ xmlhttpUpdate=GetXmlHttpObject(); if (xmlhttpUpdate==null){ alert ("Browser does not support HTTP Request"); return; } xmlhttpUpdate.open('POST', 'updateCustTbl.php', true); xmlhttpUpdate.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttpUpdate.send("a0="+a0+"a1="+a1+"a2="+a2+"a3="+a3); //xmlhttpUpdate.send(null); xmlhttpUpdate.onreadystatechange=stateUpdate; } function stateUpdate(){ if (xmlhttpUpdate.readyState==4){ var a=xmlhttpUpdate.responseText; if(trim(a) == 'update'){ alert('Successfully Updated Record'); window.location.reload(true); } } } [/ajax code] $table = 'customer_table'; $act = isset($_POST['a0']) ? $_POST['a0'] : null; $count = isset($_POST['a1']) ? $_POST['a1'] : null; $id = isset($_POST['a2']) ? $_POST['a2'] : null; $landline = isset($_POST['a3']) ? $_POST['a3'] : null; if ($act == '1'){ echo $query = "UPDATE " .$table. " SET activity='0' WHERE count='$count' AND cust_id='$id' LIMIT 1"; $result = mysql_query($query, $conn); if ($result) { echo 'update'; } else { echo "<p>Error Damn it!: " . mysql_error() . "</p>"; } } $tblCust = 'customer_table'; $sql = "SELECT * FROM " .$dump2. " WHERE count > 0 GROUP BY count ASC"; $result = mysql_query($sql,$conn); if (mysql_num_rows($result) != 0) { $pager = new PS_Pagination($conn, $sql, 8, 5, 'param1=valu1¶m2=value2'); $rs = $pager->paginate(); $x1 = '#f6f6f6'; $x2 = '#f9f9f9'; $z = 0; $x = $x2; $cnt = 0; while($row = mysql_fetch_assoc($rs)) { $date = $row['date']; $y = substr($date,0,4); $m = substr($date,4,2); $d = substr($date,6,2); $id = $row['cust_id']; $sel = mysql_query("SELECT * FROM " .$tblCust. " WHERE cust_id = '$id' LIMIT 1"); while($rows = mysql_fetch_array($sel)){ $int = $rows['count']; $lname = $rows['last_name']; $fname = $rows['first_name']; $category = $rows['pricing_category']; $landLine = $rows['land_line']; $smart = $rows['smart_num']; $globe = $rows['globe_num']; $sun = $rows['sun_num']; $address = $rows['address']; $email = $rows['email']; $name = $lname.', '.$fname; } echo "<tr>"; echo "<td height='10px' style='background-color:".$x."'>"; echo $cnt; echo "<input type='checkbox' id='chbox' name='chbox' style='cursor:pointer' onClick='validate(".$cnt.")'></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbA".$cnt."'>" .$id. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbB".$cnt."'>" .$name. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbC".$cnt."'>" .$y."/".$m."/".$d. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbD".$cnt."'>" .$category. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbE".$cnt."'>" .$landLine. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbF".$cnt."'>" .$smart. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbF".$cnt."'>" .$globe. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbF".$cnt."'>" .$sun. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbF".$cnt."'>" .$address. "</label></td>"; echo "<td height='10px' style='background-color:".$x."'><label id='lbF".$cnt."'>" .$email. "</label></td>"; echo "<td height='10px' style='display:none'><label id='lbG".$cnt."'>" .$int. "</label></td>"; echo "</tr>"; $cnt = $cnt + 1; if ($z == 0) { $x = $x1; $z = 1; }else{ $x = $x2; $z = 0; } } [/html and php] I wont complete the code in html part.... thanks in advance
-
okay I'll change my question Can somebody help me to create a php script with Digital Rights Management (DRM) Here is what I want to do : When a customer click on a link to download a content, it will save the file. But when the user/costomer will send it using Bluetooth or MMS it will not send the file to other phone. Thanks again. Hope somebody can help me ^^
-
Hi to all people, I just want to know if there a php script I can use using DRM. The scenario, once the user download the song from a website, he/she can't forward into other using bluetooth or file transfer. It is possible to do that scenario? Thanks in advance
-
Hi Peeps, I'm not sure if this is the right place to ask this . What should i use if i like to delete a file that already upload in the server. The user has the ability to delete the files if he accidentally input a wrong value to that field. It is possible in javascript or should i use a ajax. I'm just new in both script. Hope somebody here help me and reply to this topic. Thanks in advance ^^
-
Hi again Mchl, Thanks for your help. I already solve my problem...^^all i need to do is add the WHERE mobile_num = '".$temp[1].'" //select mobile number in database.... $sqlmobile = "SELECT mobile_num FROM user WHERE mobile_num = '".$temp[1]."'"; $query = mysql_query($sqlmobile); $data = mysql_fetch_array($query); if($data["mobile_num"] == $temp[1]) { echo "Mobile Number already exist!"; } Thanks again^^
-
Hi Mchl, Thanks for the reply but I dont think the insert...on duplicate key update will do...Here's my code: $sqlmobile = "SELECT mobile_num FROM user"; $query = mysql_query($sqlmobile); $data = mysql_fetch_array($query); if ($data["mobile_num"] == $temp[1]) { echo "Mobile Number already exist!"; } But its still insert into database during i run my catcher...the example i use is already exist on user table, therefore it should not insert...or it should send an error message...Hope you can help me to solve my problem... Thanks again....
-
Hi everyone... Can somebody help me to solve my problem. I have this data needed to be insert into database, but first I must check if the mobile number is already exist on may table, if not it will continue to insert. What is the correct query for this problem...Hope somebody help me... Here's my old query : insert into tgt_table select * from src_table where mobilenum NOT IN (select distinct mobilenum from tgt_table) Thanks in advance.
-
Hi to all, Can some help me to solve my problem on date query? My question is, it is possible to display the a selected date?especially if the date is base on the date subscribe by the user? The user can only view the message, where he subscribe to the latest date. Can somebody post the correct query. Thanks
-
Hi to all expert here... In mysql is there a possible that i hide a 1 of the result of query, if that result has none pair on the other table? Hope somebody could answer my question. Thanks in advance....
-
Hi to all, During I click the more button, I got this error: XML Parsing Error: junk after document element. Can somebody pinpoint why this error showed. Here is my code. Thanks in advance. PHP code: public function front2() { $session = Presto_Filter::load('UserAuth'); $user_id = $session->check(); $view = new Presto_View(); $view->title = 'KText Featured Artist'; $view->selected = $this->params['artist_id']; $all_artist = Artist::getAllArtist($user_id, 7, 6, $this->params['artist_id']); if ($this->params['artist_id'] > 0) { $selected_artist = Artist::getArtist($this->params['artist_id']); $all_artist = array_merge($selected_artist, $all_artist); } $view->top_pick = $all_artist; $view->user_id = $user_id; $all_artist = Artist::getAllArtist($user_id, 8, 7); if (count($all_artist) > 7) $view->moreArtist = true; // get the list of artist theme $view->show_themes = true; $view->themes = Theme::getAllTheme($user_id, 3); $all_theme = Theme::getAllTheme($user_id); if (count($all_theme) <= 0) $view->show_themes = false; if (count($all_theme) > 3) $view->moreThemes = true; return $view; } 1 PHTML CODE: <? Presto_Helper::load('common/header.phtml'); ?> <? if ($user_id != 0) { ?> <div class="center"> <p> <a href="inbox">Inbox (<?= $new_count ?> New Messages)</a> </p> <p> Gusto mo pa ng mas maraming ka-Ktext?<br/> Walang problema yan! </p> </div> <? } else { ?> <p> <div class=""> Gusto mo bang maging ka-text si Kris Aquino o si Piolo Pascual? Your favorite ABS-CBN celebrities are now a click away! Already subscribed? Click <a href="login">here</a> </div> </p> <? } ?> <p> <div class="header">TOP PICKS</div> </p> <div> Choose 2 artists from the list: <br /> <form method="post" action="artist/subscribe"> <table> <?= Helper_KText::artistCheckBox($top_pick) ?> </table> <p> <? if ($more) { ?> <input type="hidden" name="page" value="/artist/theme" /> <input type="submit" name="more" value="More" /><br/> <a href="artist/theme">More</a><br /> <? } ?> <input type="checkbox" name="agree" value="1" />I agree to the End User Agreement </p> <p> <input type="submit" value="Subscribe" /> <br /> ($2.99/Month)* </p> </form> </div> <? Presto_Helper::load('common/footer.phtml'); ?> 2 PHTML CODE: <? Presto_Helper::load('common/header.phtml'); ?> <? if ($user_id != 'NOMSISDN') { ?> <? } else { ?> <? } ?> <p> <div class="header">FEATURED ARTISTS</div> </p> <div> Choose 2 artists from the list: <br /> <form method="post" action="artist/subscribe"> <table> <?= Helper_KText::artistCheckBox($top_pick, $selected) ?> </table> <p> <? if ($moreArtist) { ?> <input type="hidden" name="page" value="/artist/1" /> <input type="submit" name="more" value="More" /><br/> <a href="artist">More</a><br /> <? } ?> <input type="checkbox" name="agree" value="1" />I agree to the End User Agreement </p> <p> <input type="submit" value="Subscribe" /> <br /> ($2.99/Month)* </p> </form> </div> <? if ($show_themes) { ?> <p> Oh, na-hihirapan ka bang pumili? Pumili na lang ng Ka-Ktext Artista Theme </p> <p> <div class="header">KTEXT ARTISTA THEME</div> </p> <form method="post" action="theme/subscribe"> <table> <?= Helper_KText::themeRadio($themes); ?> </table> <p> <? if ($moreThemes) { ?> <a href="theme">More</a><br /> <? } ?> <input type="checkbox" name="agree" value="1" />I agree to the End User Agreement </p> <p> <input type="submit" value="Subscribe" /> <br /> ($2.99/Month)* </p> </form> <? } ?> <? Presto_Helper::load('common/footer.phtml'); ?> The 1 phtml is where the more button appear, and the artist that user tick will appear on the 2 phtml. Thanks again ^^
-
Hi joel, Thanks for the reply, my auto increment has a large number. Now my problem is fix. Thanks again.
-
Hi joel, The id in my table was already set into id INT NOT NULL AUTO_INCREMENT. The problem is during I run my code it generate a large number and it not follow in the existing problem, is there a way or code that generate the number and follow the existing number on the table. Thanks again.
-
Hi to all, I have this code that will generate id, but the problem is I need to follow the first number in the existing id number and everytime I run my code, I generate a large id like this 1245302265407. This the code: // get artist id $sql = "SELECT id, name FROM artist WHERE name like '%$name%' "; $query = mysql_query($sql); $rows = mysql_num_rows($query); if($rows<1){ echo 'No Existing Artist ID for Artist '.$name; }else{ $record = mysql_fetch_array($query); //insert to db $id = time().rand(100,999); $sql2 = "INSERT INTO inbox (id, artist_id, date_in, content, preview, picture) VALUES( '".$id."' ,'".$record["id"]."' ,'".date("Y-m-d")."' ,'".$message."' ,'".$message."' ,'".$fname."' ) "; if(mysql_query($sql2)){ echo 'Data Inserted'; } } How I can minimize the value of my id and the generated id must be followed the existing number on the table. Thanks in advance...
-
Hi Daniel, My problem in inserting onto database, was already solve, thanks for your guide.
-
can you show me how to do it. im really new php and sql. Thanks in advance..