Jump to content

justineaguas

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Everything posted by justineaguas

  1. I want to convert a webpage from my system using PHP into a PDF file. Just how http://www.web2pdfconvert.com/ works. However, I want to have a link that says 'Convert to PDF' then it automatically converts the webpage into a PDF. Is there any way to do this?
  2. Will foreach($array as $key => $value) work? $_SESSION[cart][$key]['qty'] - Will this work? Will the whole element be deleted? Including the p_id and qty?
  3. For example, I have a session array where I put values like this: $_SESSION['cart'][] = array("qty" => $qty, "p_id" => $p_id); How will I delete one element from this array?
  4. I save the product id and quantity of an order in $_SESSION['cart'] which is an array. I am successful in adding NEW products in the array. However, when a customer buys an item again that exists in the $_SESSION['cart'] already, only the quantity will be added in the same index. That's my only problem as of now. Here is my code: if(isset($_GET['s_id']) && isset($_GET['p_id'])){ $s_id=$_GET['s_id']; $p_id=$_GET['p_id']; $qty = $_POST['qty']; if(isset($_SESSION['cart'])){ foreach($_SESSION['cart'] as $cart){ //adds quantity to existing product in array if($cart['p_id']==$p_id){ $temp = $cart['qty']; $qty = $temp + $qty; $_SESSION['cart'][] = array("qty" => $qty); } //new product in the array else { $_SESSION['cart'][] = array("qty" => $qty, "p_id" => $p_id); } } } else { $_SESSION['cart'][] = array("qty" => $qty, "p_id" => $p_id); } //displays cart information foreach($_SESSION['cart'] as $value) { echo "Product Id:" . $value['p_id'] . '<br />' . "Quantity:" . $value['qty'] . "<br />"; } $s_id = Supplier ID $p_id = Product ID
  5. Okay, I know this is an old question but I can't find good tutorials in the internet (or I'm just really the problem). Anyway, I am creating a page wherein there are 2 dropdown boxes, each of these two gets their content from the database. As the user changes the first dropdown box, the choices in the second dropdown box would change depending on the selection on the first dropdown. Here are the tables to be used. TABLE 1 - First dropdown CategoryID | CategoryName 1 | Candies 2 | Meat 3 | Seafood TABLE 2 - Second dropdown SecondCategoryID | SecondCategoryName | CategoryID 1 | Gummy Bears | 1 2 | Steak | 2 3 | Fish | 3 For example, I chose Candies in the first dropdown box, the second dropdown box would show the rows in the TABLE 2 with the CategoryID 1 and so on.. I've been searching different tutorials from the internet and from youtube but somehow I can't seem to do it with those tutorials. I know that this is possible with PHP and JS but I really need help. Thanks for future help.
  6. Hello, I want to know how to validate multiple textboxes in one form. I just studied JavaScript yesterday and I tried this code from www.w3schools.com that validates one textbox in a form. function validate_required(field,alerttxt) { with (field) { if (value==null||value=="") { alert(alerttxt);return false; } else { return true; } } } function validate_form(thisform) { with (thisform) { if (validate_required(txtProductName, "Fill it out!")==false) {return false;} } I tried adding another if statement after the code to validate other textboxes other than txtProductName. Sadly, it didn't work. Can anyone help me in validating multiple textboxes in one form only and it only shows one alert message. Please please please. Thanks for the future help!
  7. I just want to know if I can make a functions.php file where all my mySQL functions are there (insert, update, delete). So in every php file I make.. I would just include functions.php and then call any function I want to use and just enter the parameters needed. This is somehow like 'Beans' in JSP. Thank you for the additional knowledge I would get from this. JAguas
  8. I am doing a simple project right now that puts patient records in a database and displays it using HTML tables. I want to know how to have an edit button or link on the last column of the row. When the user clicks that button or link, it goes to another page wherein he/she can directly edit the information from that row. Thanks! PHP newbie
  9. I am creating a website for my project in school. Our professor requires the username of our clients to have a format. For example.. First Name: John Last Name: Williams Middle Initial: S and the username should be like jswilliams It will get the first letter of the firstname, the middle initial and the whole last name. all lower-cased characters. I have been playing with a lot of codes however I can't seem to find the correct one. I always end up wrong. How do I do this?
  10. I am using an array to check and compare the values in one variable, If the variable exists, the set of values will be inserted in the table of the variable. I am successful in inserting the values inside the mySQL table. However, I receive an error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\datbas\do_addpage_off.php on line 98 while ($row=mysql_fetch_array($result, MYSQL_ASSOC) or die(mysql_error())) //error here LINE 98 { $temp=$row['BRGY_name']; if ($temp==$brgy) { include ('connect.php'); $get = "SELECT BRGY_id FROM BRGY_info WHERE BRGY_name='$brgy'"; $res = mysql_query($get) or die(mysql_error()) or die(mysql_error()); $row = mysql_fetch_array($res, MYSQL_ASSOC); $sql = "INSERT INTO OFF_info(OFF_fname,OFF_lname,OFF_position,OFF_contact,BRGY_id,OFF_status)VALUES('$fname','$lname','$position','$contact','{$row['BRGY_id']}','$num')"; $result = mysql_query($sql) or die(mysql_error()); echo " <br /><br /> <center> Thank you for adding a new barangay.<br /> <span class='linkBody'> <a href='addpage.php'>Add Another?</a> </span> <br /> <br /> </center>"; }
  11. Oh yeaah. It is now fixed. Thanksss. I now know how to use isset. Thanks a lot
  12. I am trying a simple login/logout for my website. It works well with checking if the username exists in the database to logging in. I used $_SESSION['username']=$myusername; However, when I log-out, then I go to a page with this code <?php session_start(); if($_SESSION['username']) //line5 echo "Welcome, ".$_SESSION['username']."!<br /><a href='logout.php'>Logout.</a>"; else die ("You must be logged in!"); ?> It gives me an error. It says Notice: Undefined index: username in C:\wamp\www\datbas\member.php on line 5 I just want to know how to fix this. Thank you.
  13. It has an error. "There is no database selected" on this line trigger_error(mysql_error(),E_USER_ERROR);
  14. Yes. I have connected to the database. I know how to create databases, tables, etc. with PHP. But I'm having problems integrating HTML codes with PHP codes.
  15. Thanks to the both of you. There is no error now! However, the value is still not being inserted into the database. @Mchl I tried to replaced 'this' with 'regName'. @Andy-H I tried your code. There were no error but still the values were not inserted. Thanks really. Sorry I'm just new to PHP.
  16. Hello all, I get an error called: Parse error: parse error, expecting `'&'' or `T_VARIABLE' I just studied PHP 5 hours ago. Now I have connected to database with mySQL and all. I am trying to enter a value into the table named 'table1'. I want to insert a text into the database. The text will come from a textarea named "fname". I created a function and this is the codes. Here is the function: function insertValues(`regName`) //error in this line { mysql_query("INSERT INTO `table1` (id, fname) VALUES ('1', `".regName."`)"); } Here is the code of the form: <form action="" method="post" onclick="<?php insertValues(this); ?>> <td> <input name="regName" type="text" /> </td> <td> <input name="submit" type="submit" value="Register!" /> </td> </form> I'm just a newb. Thanks to those who will help.
×
×
  • 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.