Jump to content

dannybrazil

Members
  • Posts

    178
  • Joined

  • Last visited

Everything posted by dannybrazil

  1. This is the command (again it is NOT mine I just copied it) /** * @return the items/products list in this payment request */ public function getItems() { return $this->items; } /** * Sets the items/products list in this payment request * @param array $items */ public function setItems(Array $items) { if (is_array($items)) { $i = Array(); foreach ($items as $key => $item) { if ($item instanceof PagSeguroItem) { $i[$key] = $item; } else if (is_array($item)) { $i[$key] = new PagSeguroItem($item); } } $this->items = $i; } } /** * Adds a new product/item in this payment request * * @param String $id * @param String $description * @param String $quantity * @param String $amount * @param String $weight * @param String $shippingCost */ public function addItem($id, $description = null, $quantity = null, $amount = null, $weight = null, $shippingCost = null) { $param = $id; if ($this->items == null) { $this->items = Array(); } if (is_array($param)) { array_push($this->items, new PagSeguroItem($param)); } else if ($param instanceof PagSeguroItem) { array_push($this->items, $param); } else { $item = new PagSeguroItem(); $item->setId($param); $item->setDescription($description); $item->setQuantity($quantity); $item->setAmount($amount); $item->setWeight($weight); $item->setShippingCost($shippingCost); array_push($this->items, $item); } } example they gave - as it is // Add another item for this payment request $paymentRequest->addItem('0002', 'Notebook rosa', 2,560.00); what I want to do it getting the variables from my DB and with a WHILE loop adding the products. hope it is easier to understand now. the thing is that when I am in the WHILE loop it seems that the ($id) 0001...0002...000n is not being passed correctly in the while loop cus I am getting an error. when I just try to do it manually it is working so I guess something is wrong with the ECHO in the WHILE loop/
  2. I t is getting $productName and $price from $row_3. But it seems when I echo it , something goes wrong regarding this command (which is NOT mine I just copies it to use a shopping cart) $query_3=mysql_query("SELECT * FROM client_order WHERE Client_id = $cid AND order_number = $order_number ");[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]while ($row_3=mysql_fetch_assoc($query_3)){[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]$productName = $row_3['name']; $price = $row_3['price'];[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]echo '$paymentRequest->addItem("'.$start_number.'", "'.$productName.'", '.$price.')';[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]$start_number++; } I guess it has to be something with the echo or with the quotations or something. btw...I was trying to look for this online but couldn't : -> : what this mean...where can I find the manual for this operator (->)
  3. Hello, I have a WHILE loop that works fine, BUT when I add this to it I get an error. I guess my way is NOT how you suppose to do it My regular while: $query_3=mysql_query("SELECT * FROM client_order WHERE Client_id = $cid AND order_number = $order_number "); while ($row_3=mysql_fetch_assoc($query_3)){ echo 'smt....smt'; } I need to add: $paymentRequest->addItem('0001', 'Notebook prata', 2,430.00); // --- 0001 is increasing if I have more than 1 product 0002...000n The new one: $query_3=mysql_query("SELECT * FROM client_order WHERE Client_id = $cid AND order_number = $order_number "); while ($row_3=mysql_fetch_assoc($query_3)){ echo '$paymentRequest->addItem("'.$start_number.'", "'.$productName.'", '.$price.')'; $start_number++; } How to I write the code in a correct way that if I have lets say 3 products is will "print" 3 parts like this: $paymentRequest->addItem('1', 'Notebook prata', 2,430.00); $paymentRequest->addItem('2', 'Notebook red', 2,430.00); $paymentRequest->addItem('3', 'Notebook yello', 2,430.00); Thanks
  4. Hello I have a DB table which contains a col with information [code_of_product - quantity]: Example: 12345 - 12 , 6789 - 8 , 54321 - 3. Now as they are all in ONE CELL I wanted to know if there is a way to SEPARATE them according to the "," and "-" Like this: Product 12345 - Quantity 12 (<br>) Product 6789 - Quantity 8 . . . etc any help?
  5. Hello, I have noticed, in the last few days after uploading via DW one of my pages keeps adding ">" sign after the closing HTML. Example: </html>>>>> Lets say I delete it....and after again it appears, sometimes more ">" </html>>>>>>>>>>>> The things is that it is NOT in the middle of the code, so I didn't forget to "close" some TAGS. any idea about what it is? Danny.
  6. The part called "collation" in the DB, should be UTF8, you mean? ok I have a list of 20+ utf8_ there is no utf8_portuguese . should I choose. utf8_unicode_ci ??
  7. Hello My site is in PORTUGUESE (charset=iso-8859-1"). so a users name could be, for example: Marcus Marcos M?rcos Marc?s ?,?,?, ?, ?, etc.... I have an option that allows to search users on my page. I use %LIKE% in my code, but it is not working correctly. If the user name is Marcus and someone is looking for M?rcus it doesn't return anything Is there a way to disregard ACCENTS while SQL searching? just letters, pure? Danny.
  8. Hello there, I have a DB table where everyday I insert my meetings for the future. I want to ask you guys if anybody can help me with creating some sort of a weekly report. EXAMPLE: I have meeting from the beginning of the year (Mon-Sat)...could be 4-10 meeting per day, so a lot in general. I want them to appear , with sql, under the WEEK they were in for example: (a year has 52 weeks) WEEK 1 (01-01-2011 -> 08-01-2011) *M1 *M2 *M3 ... WEEK 2 (09-01-2011 -> 16-01-2011) *M4 *M5 *M6 ... etc... Is there a way to define the date's range after the week ended automatically? Thanks
  9. I have founf another code that works....shaped it and it is working smoothly foreach($_POST['student_id'] as $row=>$Act) { $student_id = mysql_real_escape_string($Act); $student_name = mysql_real_escape_string($_POST['student_name'][$row]); $student_email = mysql_real_escape_string($_POST['student_email'][$row]); $teacher_name = mysql_real_escape_string($_POST['teacher_name'][$row]); $grp = mysql_real_escape_string($_POST['grp'][$row]); $date = mysql_real_escape_string($_POST['date'][$row]); $date_dd = mysql_real_escape_string($_POST['date_dd'][$row]); $date_mm = mysql_real_escape_string($_POST['date_mm'][$row]); $date_yy = mysql_real_escape_string($_POST['date_yy'][$row]); $att = mysql_real_escape_string($_POST['att'][$row]); $involv = "INSERT INTO table (`student_id`,`student_name`,`student_email`,`teacher_name`, `grp`, `date`, `date_dd`, `date_mm`, `date_yy`, `att` ) VALUES('$student_id', '$student_name', '$student_email', '$teacher_name','$grp','$date','$date_dd','$date_mm','$date_yy','$att')"; mysql_query($involv); } Thnaks a lot for the people who help !!!!!!
  10. Hi I have this code: $insertVals = array(); foreach($_POST['att'] as $studentID => $attended) { $grp = $_POST['grp'][$studentID]; $date = $_POST['date'][$studentID]; $insertVals[] = "('$studentID','$grp','$date','$attended')"; } //Create and run INSERT query $query = "INSERT INTO student_attendance ('student_id','grp','date','att') VALUES " . implode(',', $insertVals); mysql_query($query) or die (mysql_error()); But get this problem: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''student_id','grp','date','att') VALUES ('4','WE001','2011-08-19','Yes' at line 2 Any reason ?
  11. I do have MORE <input> to add <input type="hidden" name="student_id" value="'.$id_st.'" /> <input type="hidden" name="student_name" value="'.$st_name.'" /> <input type="hidden" name="student_email" value="'.$st_email.'" /> <input type="hidden" name="teacher_name" value="'.$teacher.'" /> <input type="hidden" name="grp" value="'.$grp.'" /> <input type="hidden" name="date" value="'.date('Y-m-d').'" /> <input type="radio" name="att['.$id_st.']" value="Yes" />Yes | <input type="radio" name="att['.$id_st.']" value="No" />No //original INSERT mysql_query("INSERT INTO student_attendance (`student_id`,`student_name`,`student_email`,`teacher_name`, `grp`, `date`, `date_dd`, `date_mm`, `date_yy`, `att` ) VALUES ('$_POST[student_id]','$_POST[student_name]','$_POST[student_email]','$_POST[teacher_name]','$_POST[grp]','$_POST[date]','$_POST[date_dd]','$_POST[date_mm]','$_POST[date_yy]','$_POST[att]' )") or die(mysql_error()); How to I add MORE var' to the code you gave me here: $insertVals = array(); foreach($_POST['attend'] as $studentID => $attended) { $insertVals[] = "('$studentID', '$attended')"; } //Create and run INSERT query $query = "INSERT INTO attendance (`studentID`, `attended`) VALUES " . implode(', ', $insertVals); $result = mysql_query($query) or die (mysql_error());
  12. I have found this code....work fine..but how can I add multipule form entries. In this example we have 'student_id' ONLY..how do I add for example: 'date' and 'name' etc... <form method="POST" action="insert.php"> <input type="checkbox" name="id[]" value="32">Article #32<br> <input type="checkbox" name="id[]" value="38">Article #38<br> <input type="checkbox" name="id[]" value="45">Article #45<br> <input type="checkbox" name="id[]" value="59">Article #59<br> <input type="Submit"> </form> $query = 'INSERT INTO related_articles (id) VALUES (' . implode('), (', $_POST['id']) . ')'; $result = mysql_query($query) or die('Could not execute INSERT query'); Now I want to add as well $_post['date'] / $_post['name']....where do I add it ?
  13. Hello, I have an attendance form that looks like that (It automatically adds the students names and info) student 1 DATE Att [yes/no] (radio) student 2 DATE Att [yes/no] (radio) . . student N SUBMIT Now I want that each student will get a DIFFERENT ROW in the DB table. id name date att 1 st1 2011-01-01 yes 2 st2 2011-01-01 no . . n Is there a smart way to do so ? Thanks
  14. Hello, I have a DB with lots of rows...some sort of comments for each article. Lets say the articles have an ID (AR001,AR002...AR100). Each author write articles freely, so I cant know how many each has. Now each article gets various numbers of comments, which I cannot know before hand, and the ROW ID is mixed. I want to print the authors, their articles (ordered) and comments for each. The thing is...how do I capture ONLY ONCE the article code? I mean id AR001 has 100 comments, how do I get JUST the article code ONCE and then another while loop to get the comments. Ex. Danny Sheps Article 1 comment 1 comment n Article 2 comment 1 comment n Article n comment 1 comment n hope you got it....Thanks
  15. $message = " $t_n, \n\n Your original comments:\n $o_comment\n\n <b>$s_n</b> commented about your assessment: \n $text "; mail($t_e , $header, $message, "From: \"E4U2 - Assessment\" <info@english4u2.com.br>\r\n" . "X-Mailer: PHP/" . phpversion());
  16. Hi guys I am going NUTS. why when I send an e-mail with php I cannot add CSS/DESIGN I always get the text in the e-mail body like this : <b>words</b> INSTEAD of words I tried it with squared brackets...nothing
  17. WOW...that was FAST... I will check it soon and let you know Thanks A LOT !!!
  18. Exactly! But I don't/cannot know the STUDENT'S name BEFORE. I need the code to get ALL the names and then check for similarity or smt
  19. Hello people, I have a question, and I hope someone can SAVE me here. I have a DB table with these columns: teacher_name Student_name Comment date Now I have for example 1000 students but every day a teacher writes a comment for a student. NOT ALL STUDENTS have comments. what I want to do: when a teacher enters his backoffice page, he would be able to get from the DB ONLY the students he wrote comments to. But the thing is, he wrote, let's say, 100 comments, TO 20 students. Is there a way to have a code that: Gets the TOTAL comments of this teacher separate it to STUDENT names and give me an output with the names that I could print the results only for these 20 students and NOT all Hope you got it
  20. Hello, I have a list of 100 emails in a .txt file, and I wanted to UPLOAD them into a database, but each email into 1 row. e.g. TXT FILE xxxx@xxxxx.com,xxxx@xxxxx.com,xxxx@xxxxx.com,xxxx@xxxxx.com,...xxxx@xxxxx.com into DB row1-->xxxx@xxxxx.com row2-->xxxx@xxxxx.com ... row100-->xxxx@xxxxx.com any help how to do so ?
  21. I have found this script $text = ' email@domain.com '; function parseTextForEmail($text) { $email = array(); $invalid_email = array(); $text = ereg_replace("[^A-Za-z._0-9@ ]"," ",$text); $token = trim(strtok($text, " ")); while($token !== "") { if(strpos($token, "@") !== false) { $token = ereg_replace("[^A-Za-z._0-9@]","", $token); //checking to see if this is a valid email address if(is_valid_email($email) !== true) { $email[] = strtolower($token); } else { $invalid_email[] = strtolower($token); } } $token = trim(strtok(" ")); } $email = array_unique($email); $invalid_email = array_unique($invalid_email); return array("valid_email"=>$email, "invalid_email" => $invalid_email); } function is_valid_email($email) { if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$",$email)) return true; else return false; } var_dump(parseTextForEmail($text)); How to I get ONLY the emails to be printed: xxxx@xxxx.com, xxxx@xxxx.com, xxxx@xxxx.com Thanks
  22. Hello, I have a list of EMAILS which I want to clean. ex. adriano171@gmail.com; Adriano Gomes BenĂ­cio <adriano171@gmail.com>; "afonso.leirias@gmail.com" <afonso.leirias@gmail.com>; I would like to CLEAN the list and get ONLY the email address like this: xxxx@xxxxxxxx.com, xxxx@xxxxxxxx.com.br It means removing /names/ < / > / " / ;/ and add a COMA after each email. I have this code, but it doesnt clean ALL $patterns = array(); $patterns[0] = '/;/'; $replacements = array(); $replacements[2] = ',<br>'; echo preg_replace($patterns, $replacements, $string); any help ?
  23. Can anybody help me here, I have this code that I have NO clue whats wrong, in other pages it it working if ($_POST['submit'] == 'Edit Report') { $id = $_REQUEST['id']; $group = $_POST['group']; $group_clean = mysql_real_escape_string($group); $report = $_REQUEST['report']; $report_clean = mysql_real_escape_string($report); mysql_query(" UPDATE teacher_report SET group='$group_clean' , report='$report_clean' WHERE id=$id ") or die(mysql_error()); header("Location: report.php?msg=Your report was edited Successfully!"); exit; } I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group='Gestamphhh' , report='checking' WHERE id=1' at line 1 help ?
  24. Hello, I have a code that adds 1 month to a specific date every month. $newdate = strtotime ( '+1 month' , strtotime ( $b_date ) ) ; $new_date = date ( 'Y-m-d' , $newdate ); the thing is some month of the year do not contain the SAME amount of days. For example: If the date was 2011-01-31 + 1 month = 03-03-2011 Is there any way to add a month (+1 month) but make it consider the calendar. lets say that I had 2011-01-31 --> +1 month == 2011-28-02 (the last day of the next month if there is NO similar days in month Thanks
×
×
  • 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.