Jump to content

Andrew R

Members
  • Posts

    158
  • Joined

  • Last visited

    Never

Everything posted by Andrew R

  1. Thanks a million for that One thing though, How would I get the corresponding rows to match up? I tried the following.... <?php for($i = 1; $i <= $_POST['fieldnums']; $i++) { $description = $_POST['description']; $price= $_POST[price]; mysql_query("INSERT INTO table_name_here_break_down (description,price) VALUES ('$description[$i]','$price[$i]')") or die (mysql_error()); } ?>
  2. For example I have the following form array <?php $how_many_fields = $_POST['how_many_fields']; for ($i = 1; $i <= $how_many_fields; $i++) { ?> <input name="description[]" type="text" id="description[]"> <input name="price[]" type="text" id="price[]" /> <?php } ?> and I am trying to insert the data into a table.
  3. Hi there. Why does the following code not work or if it isn't possible how would I do something to the same effect? <?php foreach($_POST["description"] as $description && $_POST["price"] as $price) { ///do stuff here } ?> Thanks a million!
  4. Hi there Does anybody have any information on how to parse an xml in document in PHP 4? Are there any easy to use classes that do this? Or is there a similar function in PHP 4 like SimpleXMLElement? Many thanks
  5. ....like the following scripts below...or is the following way far to bloated? form.inc.php <?php function form_html(); { ?> <form action="<? $_SERVER['PHP_SELF']; ?>" method="post"> <label> Name <input name="name" type="text" id="name" /> </label> <br /> City: <label> <input name="city" type="text" id="city" /> </label> <p> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> </form> <?php } function form_process() { $name = $_POST['name']; $name = $_POST['city']; ////INSERT INTO DATABASE HERE }?> form.php <?php require("form.inc.php"); if(isset($_POST['submit'])) { form_process(); header("Location: index.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php form_html(); ?> </body> </html>
  6. Thanks very much. Writing the form html as a function and the php process of the form as a function in separate files and including them in one page a suitable way to handle forms or is that completely over engineering it. Should the form_process() and the form_html() functions be included in the same file such as form.inc.php and then each part of the function included in a separate file such as form.php recommended?
  7. Hi What is the best way to handle forms taking into consideration security and efficiently - For example is it better to have the html form on one page and then do the php processing on another? Or is it better to write a function for the html form and a function for the processing and call them into one page. For example <?php function edit_form_pro(); { PHP PROCESSING FUNCTIONS HERE } ?> <?php function edit_form(); { ?> <html goes here> <?php } ?> Many thanks.
  8. I'm very impressed with XAMPP. Although it’s a bit of a struggle in working out how to change the phpMyAdmin password. Although is there any point having a password for phpMyAdmin on testing server as I'm going to be the only user? Which leads onto my next question.... Is it possible for somebody to simply type my IP address in and view the files/phpMyAdmin etc or is there a security feature in either XAMPP or Windows that disables this? Many thanks.
  9. Sorry, not sure where else to post this? I was wondering what you think is the best WAMP Server in terms of functionality, usability, security, support etc taking into consideration it will only be used as a testing/development server when I'm not connected to the internet. There seems to be a quite a number of them out there and I'm confused on which one is the best for this purpose. I’ve tried AppServ and WampServer and they run perfectly but I’m wondering what other ones people recommend. As a bare minimum I need http apache and phpmyadmin installed and a simple user interface that allows me to stop the server so it's not running when I'm connected to the internet. Many thanks.
  10. Below shows the HTML and CSS used for a centred 2 column layout. I was wondering why the container div was not stretching the whole length of the two columns? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- #container { width: 900px; margin-right: auto; margin-left: auto; background-color: #FFFFFF; height: 100%; border: 1px solid #000000; } #left { width: 50%; background-color: #CCCCCC; float: left; } #right { width: 50%; background-color: #EEEEEE; float: left; } body { background-color: #33CC33; } --> </style> </head> <body> <div id="container"> <div id="left">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. </div> <div id="right">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. </div> </div> </body> </html> Many thanks
  11. Hello Does anyone know of a good script that take data from a MYSQL database and displays it in an RSS feed? Many thanks
  12. Thanks for the reply I just wanted to use a lightweight script instead.
  13. Hello I am using the following script to populate a drop down date input (Day, Month, Year) var monthtext=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sept','Oct','Nov','Dec']; function populatedropdown(dayfield, monthfield, yearfield){ var today=new Date() var dayfield=document.getElementById(dayfield) var monthfield=document.getElementById(monthfield) var yearfield=document.getElementById(yearfield) for (var i=0; i<31; i++) dayfield.options[i]=new Option(i, i+1) dayfield.options[today.getDate()]=new Option(today.getDate(), today.getDate(), true, true) //select today's day for (var m=0; m<12; m++) monthfield.options[m]=new Option(monthtext[m], monthtext[m]) monthfield.options[today.getMonth()]=new Option(monthtext[today.getMonth()], monthtext[today.getMonth()], true, true) //select today's month var thisyear=today.getFullYear() for (var y=0; y<20; y++){ yearfield.options[y]=new Option(thisyear, thisyear) thisyear+=1 } yearfield.options[0]=new Option(today.getFullYear(), today.getFullYear(), true, true) //select today's year } There is a problem in that the script displays the current date + 20 years in advance. How would I modify the script to display the current date but also the years before it. Many thanks
  14. As easy as that Thanks very much!
  15. I have the following form array..... <form id="form1" name="form1" method="post" action="post.php"> <label> <input name="user_id[]" type="checkbox" id="user_id[]" value="1" /> </label> Andrew<br /> <label> <input name="user_id[]" type="checkbox" id="user_id[]" value="2" /> </label> Jim<br /> <label> <input name="user_id[]" type="checkbox" id="user_id[]" value="3" /> </label> James </form> How would I combine user_id[] into 1 variable which would contain the values separated by a comma so it could be passed into a sql statement. Many thanks
  16. I was wondering why the following script does not work. Basically I want to output each name in a separate text box, separates by a comma. <? $users = array("".$user['user_name'].""); $users = str_replace(" ", "", $users); foreach($users as $key => $value) { ?> <input type="text" value="<? echo $value; ?>" /> <? } ?> The format of user_name is, Andrew,Bob,James,Jim.
  17. Thanks for the reply. All fields are correct and the error is 'mysql_error'. Many thanks.
  18. Can anybody see why the following sql query gives an mysql_error? $clients_q = mysql_query("SELECT * FROM organisations where organisation_Id = (SELECT organisation_id FROM hosting WHERE server_id = '1')") or die(mysql_error); $clients = mysql_fetch_array($clients_q); $total_users = mysql_num_rows($clients_q); Many thanks
  19. Hi there. I have the following script. I was wondering why the SQL results won’t display inside the function? How do I pass sql results inside the function? <? $name_q = mysql_query("SELECT * FROM users where name = 'Andrew'") or die(mysql_error); $name = mysql_fetch_array($name_q); function test() { echo $user['name']; } test(); ?> Many thanks
  20. Hi How much data can be stored in a php cookie? If there is a limit is it possible to increase it? Many thanks
  21. lol, I know it's a mess lol Thanks a million for you your help webster08
  22. Hi. I wrote this script to submit two forms on the one page. It works in IE and Safari but not in Firefox. Can anybody see why? The in error in Firefox is, document.myform is undefined. <? if(isset($_POST['go'])) { ////perform other functions here ?> <form name="myform" method="post" action="test.php" target="_blank"> <input name="name" type="hidden" id="name" value="<? echo $_POST['name']; ?>" /> </form> <SCRIPT language="JavaScript"> document.myform.submit(); </SCRIPT> <? } ?> <form name="contact_form" method="post" action="<? $_SERVER['PHP_SELF']; ?>"> <label> <textarea name="name" id="name"></textarea> </label> <br> <label> <input name="go" type="submit" id="go" value="Submit"> </label> </form> Any help would be much appreciated Cheers
  23. I was wondering if anybody knew how to parse some of the html from cPanel? For example I would like to Parse the cPanel account summary. I would be extremely grateful if somebody could show me how to parse some basic html. Even just text from a simple table. For example how would I parse the name Andrew via php from the table below? <table width="100%" border="0"> <tr> <td width="40%">Name:</td> <td width="80%"> Andrew</td> </tr> <tr> </table> Many 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.