Jump to content

giraffemedia

Members
  • Posts

    180
  • Joined

  • Last visited

    Never

Everything posted by giraffemedia

  1. Hi Jay, if you read my 2nd post you'll see I can only enter a regex for validation.
  2. Hi Thorpe, It's for a Joomla component and I haven't got a lot of control over other aspects or filtering. I need a php regex that allows any number from 18-99 but nothing else. James
  3. Hello, I'm trying to put together a regex that validates a two number input. I want a person to enter their age but it has to be 18 or over and up to 99. I've tried using ^([1-9][8-9])$ but obviously that only validates 18, 19, 28, 29, 38, 39 etc missing out the other numbers. Can anyone help please?
  4. No worries i've just figured it out. It's [1-9][8-9] James
  5. hello, I'm trying to put together a regex that validates a two-digit number if it's over 17 i.e. 18 of more. Can anyone help, i'm not terribly hot on regex stuff. Thanks, James
  6. Hello, I want to put together a little script that does the following but I'm not sure how to approach it… 1 - user chooses a csv file up to 5mb in size filled with competition entries. There is one competition entry per line. 2 - The contents of this csv then load into a html textarea on the page 3 - The user clicks a 'pick winner' button and the script chooses a random line from the textarea and assigns it to the variable $winner which prints to the browser 4 - If the user wishes they can click on the button to select more winners if necessary. I'm a bit stumped about the best way to do this. I don't really want to get into uploading the csv file to a directory permanently. Can anyone point me in the right direction for doing this please? Thanks, James
  7. Hello, I have two functions in my document that convert anything in a string between the characters [] as a link <a href="example.com">example</a> or {} as a paragraph <p class="example">example</p> like so… Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet, ante et blandit fermentum, [www.example.com] sem elit fermentum odio, sit amet sagittis arcu libero vitae nunc. Sed sed viverra diam. Etiam tristique sagittis neque id aliquet. {Etiam quam enim, vestibulum nec hendrerit nec, faucibus ut est.} Donec vel orci eu elit pretium euismod ac vitae nisi. Praesent scelerisque aliquet nunc vel ultrices. Praesent interdum massa at dolor tempus aliquet. What I would like is a new function that wraps all other text in <p></p> tags but leaves the one's I have already processed. I want it to look like the following… <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <p>Sed aliquet, ante et blandit fermentum, <a href="www.example.com">www.example.com</a> sem elit fermentum odio, sit amet sagittis arcu libero vitae nunc. Sed sed viverra diam. Etiam tristique sagittis neque id aliquet.</p> <p class="example">Etiam quam enim, vestibulum nec hendrerit nec, faucibus ut est.</p> <p>Donec vel orci eu elit pretium euismod ac vitae nisi. Praesent scelerisque aliquet nunc vel ultrices. Praesent interdum massa at dolor tempus aliquet.</p> Is it possible to write one function that does all of this in one? Thanks, James
  8. You sir, are a bloody genius! Do you know of somewhere I can learn about regex apart from the php online manual, I find that too complicated Thanks for your help, James
  9. Hi, I'm trying to write a function that finds all text within a string beginning with [[ and ending with ]] and manipulates the content between them. For example: This is some sample text and [[Debenhams||debenhams.com]] and this is a bit more sample text that [[sainsburys||sainsburys.com]] What I want to do is turn the bits between the brackets into links, using the first piece of text as the link name and the second as the link url. What I need is a function that replaces every instance of the bracketed code with the link text. Here is what I have so far which is working. function get_string_between($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $fullstring = "Here is some link text [[Debenhams||debenhams.com]] my"; $parsed = explode("||", get_string_between($fullstring, "[[", "]]")); echo '<a href="http://www.'.$parsed[1].'" title="Visit the '.$parsed[0].' website" target="_blank">'.$parsed[0].'</a>'; // (result = link to Debenhams) What I cannot figure out is how to write a function that searches a string and replaces all the bits between the brackets with the links. I'd really appreciate some help please.
  10. To add to that, if you want the max booking number for all forms then this should do the trick SELECT booking_form_number, MAX(issue_number) FROM table_name GROUP BY booking_form_number That worked great thanks. I had to tweak it a bit to get it to work how I needed but the MAX() bit was the key. I ended up with the following… $issue_numbers = mysql_query("SELECT ib_booking_form_number,ib_issue_number, MAX(ib_issue_number) AS end_issue FROM issues_booked GROUP BY ib_booking_form_number") or die(mysql_error()); while($row = mysql_fetch_array($issue_numbers)){ if ($row['end_issue'] == $_GET['issue_number']) { $booking_number[] = $row['ib_booking_form_number']; } } Thanks very much everyone. James
  11. Hello, I have a table in my database that contains a list of issuse_numbers, each with a corresponding booking form number next to it like below… id(primary) issue_number booking_form_number 12306 92 3089 12305 93 3088 12304 92 3088 12303 94 3087 12302 93 3087 12301 92 3087 12300 112 3085 12299 111 3085 12298 110 3085 12297 109 3085 12296 108 3085 12295 107 3085 12294 106 3085 12293 105 3085 12292 104 3085 12291 103 3085 12405 103 3080 12404 102 3080 12403 101 3080 12402 100 3080 12401 99 3080 12285 98 3079 12284 97 3079 12283 96 3079 12282 95 3079 12281 94 3079 12280 93 3079 12279 92 3079 12278 91 3079 12365 92 3078 12364 91 3078 12363 90 3078 I would like to be able to find out the best way of getting the last issue number for any booking form. Is this a mysql query related thing in addition to using the php end function? I'm not sure how to group the rows together so I get something like… 91, 92, 93, 94, 95, 96, 97, 98 for booking number 3079 90, 91, 92 for booking number 3078 etc etc I would appreciate any help as it's driving me nuts! James
  12. Works like a dream, and I understand your point about overwriting the variable. Thanks very much. James
  13. I'm not sure how I access the array though I've tried the following with no success… function advert_type($advert_string) { $advert_type = explode(' - ', $advert_string); $advert_type = $advert_type[0]; $advert_type_choice = $advert_type[1]; return array($advert_type ,$advert_type_choice); } $test = 'Test - Value'; list ($advert_choice) = advert_type($test);
  14. Hello, is it possible to access two variables from a single function if I'm using explode to split a string? Something like… function advert_type($advert_string) { $advert_type = explode(' - ', $advert_string); $advert_type = $advert_type[0]; // Variable 1 $advert_type_choice = $advert_type[1]; // Variable 2 return $advert_type; return $advert_type_choice; } echo advert_type('Test - Value'); Thanks, James
  15. Hi, I'm putting together a database that once logged in, a user is able to insert, update and delete records via html forms. The login is secured using mysql_real_escape_string, but I'm wondering should I do the same for all form elements that pass data to the db? There are a wide range of inputs, from numeric, alphanumeric, dates and more. I'd appreciate your feedback. Regards, James
  16. Works like a charm Porl123! I had to add an if isset statement around the whole script to stop it giving me errors if the array was empty but apart from that great. Thanks, James
  17. Hi I have a form populated with an array of checkboxes (with labels). When I submit the form to the same page none of the checkbox values are remembered. What is the best way of achieving this? If I echo the checked box values it tells me which ones were selected but I cannot get the actual boxes to remember if they were checked or not. Here is what I have… $checked = $_POST['issue']; foreach($checked as $item) { echo "Item $item was checked<br />"; } while ($row = mysql_fetch_array($issue_query)) { $issues[] = '<span style="display:block;margin:0px 0px 10px 60px;"><input name="issue[]" type="checkbox" style="width:auto;" value="'.$row['issue_number'].'">Issue <strong>'.$row['issue_number'].'</strong> '.$row['issue_month'].' '.$row['issue_year'].'<span>'; } Any ideas? Thanks, James
  18. Hi, i've tried searching for this but had no luck. I want to be able to select 3-4 random strings of text from a group of about 10, but i'm unable to get the right result. The strings will contain html tags that have a h4, p and img tags to display a random selection of products. I've tried the following but had no luck. Does anyone have an idea of what I should be doing? $product_1 = '<h2>Test Product 1</h2><p>skdug sdkhg ks dkghjs kjsd jhfs dfklj</p><img src="images/test/test1.gif" align="left" height="50" width="50" border="0" />'; $product_2 = '<h2>Test Product 2</h2><p>skdug sdkhg ks dkghjs kjsd jhfs dfklj</p><img src="images/test/test2.gif" align="left" height="50" width="50" border="0" />'; $product_3 = '<h2>Test Product 3</h2><p>skdug sdkhg ks dkghjs kjsd jhfs dfklj</p><img src="images/test/test3.gif" align="left" height="50" width="50" border="0" />'; $products = array($product_1, $product_2, $product_3); echo rand($products); Thanks, James
  19. Hello, i'm trying to get the URL of the page in the browser from within a page that has been included from a different server. When I use $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"] to view the current URL it's giving me the URL of the page i'm including, not the page the viewer is seeing. Is it possible to get the original browser URL from with an included page, or do I have to pass a variable between the two pages? Thanks James
  20. Hello, i've put together a little page to strip html comments from a dreamweaver template that I use for putting newsletters together. It's working fine now but i'd appreciate any input on the security side of things or general comments if you have any. I'm also looking to get the form to check for any comments embedded within comments to sort out any that have nested (not that they should be - but you never know) but i'm not sure on the regex for that so if anyone has any ideas that would be great. Thanks James <? if (isset($_POST['submit'])) { // If the form has been submitted $input_string = stripslashes($_POST['input']); // Stripslahes from the html $result = preg_replace('/<!--(.|\s)*?-->/', '', $input_string); // Replace the opening and closing comments tags with nothing } $result = htmlentities($result); // Keep the output as html code rather than the browser interpreting the code and showing the actual page ?> <!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=UTF-8" /> <title>Strip Comments for Newsletter</title> <style> body {margin:10px auto; text-align:center; font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size:12px;} fieldset {padding:30px; border:none; background-color:#CCC;} legend {background-color:#666; padding:5px 20px;color:#FFF;} textarea {width:100%; font-size:11px; line-height:20px; padding-left:10px;} </style> </head> <body> <div style="margin:10px 200px;"> <h1>Strip Comments</h1> <p>This script will strip out html comments from a web page but preserve the rest of it.</p> <p>Simply paste the html into input and click 'Strip'. You will then be presented with the stripped version.</p> <form action="" method="post" name="input" target="_self"> <fieldset> <legend>Input</legend> <textarea name="input" rows="10"><? echo $input_string; // Keep the code i've just stripped ?></textarea> <br /> <input name="submit" type="submit" value="Strip it baby!" /> </fieldset> <br /><br /><br /> <? if (isset($_POST['submit']) && (!empty($result))) { echo ' <fieldset> <legend>Output</legend> <textarea name="output_text" rows="10" >' . $result . '</textarea> <br /> <input type="button" value="Select All" onClick="javascript:this.form.output_text.focus();this.form.output_text.select();"> </fieldset>';} else {} // Return the output in a new fieldset with a button to select the code ?> </form> </div> </body> </html>
  21. You're right Justin, thanks for pointing that out. I've made an if statement and put it into the second form action like so... if (isset($_POST['form_set']) && (mysql_num_rows($company_name_result) < 1) && (!empty($_POST['clienttype'])) && (!empty($_POST['companyname'])) && (!empty($_POST['sales_contact'])) && (!empty($_POST['client_lead'])) && (!empty($_POST['pre_payment']))) { $submit = 'includes/insert_record_process.php'; } else { $submit = ''; } So that if all conditions are met the script executes the form action and if not there is no action and the page keeps submitting to itself until it is correctly filled in. James [/code]
  22. Hello, i'm trying to put together a form to insert records into a database. I have had the form working fine but i want to add some validation after several users missed out important information using the page. I have a page set up with an if statement choosing one of two pages depending on whether a hidden field (on the validated page) has been set. The problem I have is when the form passes all validation and redirects to the insert script (to insert the input values from the validated form) page no data gets inserted. As I have the two html pages on the one php page it's almost like it's inserting the first unfilled page rather than the validated one. Is this what's going on? Can anyone shed some light on this? Here is my code Regards James <?php // Start the session session_start(); // Check to see if the session has been set already - of not redirect to login page if(!isset($_SESSION['Login'])) header ("location:login.php"); // Include neccessary set up files include ('../config.php'); include ('../opendb.php'); // LIST OF ERROR VARIABLES................. $error_companyname = '<span class="form_error">*ERROR* - No company name</span>'; $error_companyname_taken = '<span class="form_error">*ERROR* - Company name already exists!</span>'; $error_client_type = '<span class="form_error">*ERROR* - No client type</span>'; $error_sales_contact = '<span class="form_error">*ERROR* - No sales contact</span>'; $error_companyname = '<span class="form_error">*ERROR* - No company name</span>'; $error_booking_type = '<span class="form_error">*ERROR* - No booking type</span>'; $error_pre_payment = '<span class="form_error">*ERROR* - No pre-payment</span>'; // Define the company name variable $company_name = $_POST['companyname']; // Make the query to find all results with the company name entered $company_name_query = "SELECT companyname FROM contacts WHERE companyname = '$company_name'"; $company_name_result = mysql_query($company_name_query); if (!$company_name_result) { echo 'Query Error: ' . mysql_error(); } // If all neccessary fields are filled in.... if (isset($_POST['form_set']) && (mysql_num_rows($company_name_result) < 1) && (!empty($_POST['clienttype'])) && (!empty($_POST['companyname'])) && (!empty($_POST['sales_contact'])) && (!empty($_POST['client_lead'])) && (!empty($_POST['pre_payment']))) { header ("location: check.php"); } if (!isset($_POST['form_set'])) { ?> <!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>Customer Management - Enter a new record</title> <link rel="stylesheet" type="text/css" href="styles/database.css"/> <link rel="icon" href="favicon.ico" type="image/x-icon"/> <script language="javascript" type="text/javascript" src="date_picker/datetimepicker.js"></script> </head> <body> <div id="wrapper"> <div id="header"></div> <div id="main_nav"> <?PHP include ("nav/main_nav.php"); ?> </div> <div id="main_content"> <h1>Please enter the customer details</h1> <form action="" method="post" onsubmit="return validate_form(this)"> <input name="form_set" type="hidden" value="true" /> <table width="700" border="0" cellpadding="0" cellspacing="0" id="data_container"> <tr> <td width="600" valign="top"><fieldset><legend>Company Details</legend> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="single_line_table"> <tr> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Company Name:</strong> <input name="companyname" type="text" id="companyname" tabindex="1" /> </p> </td> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Booking Type:</strong> <select name="client_lead" id="client_lead" tabindex="5" > <option value="" selected="selected">Please choose...</option> <option value="">-------------------</option> <option value="C">Client</option> <option value="L">Lead</option> </select> </p> </td> </tr> <tr> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Client Type:</strong> <select name="clienttype" id="clienttype" value=""> <option value="" selected="selected">Please choose...</option> <option value="">-------------------</option> <? // Populate the Advertiser Type drop down menu $sql = mysql_query("SELECT client_type_name FROM client_types"); $num = mysql_num_rows($sql); $i=0; while ($i < $num) { $item = mysql_result($sql,$i,"client_type_name"); $i++; echo '<option value="' . $item . '">' . $item . '</option>'; } ?> </select> </p> </td> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Pre Payment:</strong> <select name="pre_payment" id="pre_payment"> <option value="" selected="selected">Please choose...</option> <option value="">-------------------</option> <option value="Y">Yes</option> <option value="N">No</option> </select> </p> </td> </tr> <tr> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Sales Contact:</strong> <select name="sales_contact" id="sales_contact"> <option value="" selected="selected">Please choose...</option> <option value="">------------------</option> <? // Populate the Section drop down menu $sql = mysql_query("SELECT * FROM users WHERE sales = 'Y'"); $num = mysql_num_rows($sql); $i=0; while ($i < $num) { $firstname = mysql_result($sql,$i,"firstname"); $lastname = mysql_result($sql,$i,"lastname"); $i++; echo '<option value="' . $firstname . ' ' . $lastname . '">' . $firstname . ' ' . $lastname . '</option>'; } ?> </select> </p></td> <td width="50%" align="right" valign="middle"><p class="form_details"><strong>Business Type:</strong> <input name="businesstype" type="text" id="businesstype" tabindex="2" /> </p></td> </tr> <tr> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Advertising In:</strong> <select name="advertisingin" id="advertisingin"> <option value="Wedding Ideas" selected="selected">Wedding Ideas</option> </select> </p></td> <td width="50%" align="right" valign="middle"><p class="form_details"> </p></td> </tr> </table> </fieldset> <tr> <td valign="top"><fieldset><legend>Contact Details</legend> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="single_line_table"> <tr> <td width="50%" align="right"><p class="form_details"><strong>(1) First Name:</strong> <input name="contactonefirstname" type="text" id="contactonefirstname" value="<?=$onefirstname;?>" tabindex="6" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>(2) First Name:</strong> <input name="contacttwofirstname" type="text" id="contacttwofirstname" tabindex="9" /></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>(1) Last Name:</strong> <input name="contactonelastname" type="text" id="contactonelastname" value="<?=$onelastname;?>" tabindex="7" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>(2) Last Name:</strong> <input name="contacttwolastname" type="text" id="contacttwolastname" tabindex="10" /></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>(1) E-mail:</strong> <input type="text" name="contactoneemail" id="contactoneemail" value="<?=$oneemail;?>" tabindex="8" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>(2) E-mail:</strong> <input type="text" name="contacttwoemail" id="contacttwoemail" tabindex="11" /></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Website:</strong> <input name="website" type="text" id="website" /></p></td> <td width="50%" align="right" valign="top"> </td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Phone:</strong> <input name="phone" type="text" id="phone" value="<?=$phone;?>" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>Fax:</strong> <input type="text" name="fax" id="fax" /></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Mobile:</strong> <input type="text" name="mobile" id="mobile" /></p></td> <td width="50%" align="right" valign="top"> </td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Address:</strong> <input name="address" type="text" id="address" value="<?=$address;?>" /></p></td> <td width="50%" align="right" valign="top"> </td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Town/City:</strong> <input name="towncity" type="text" id="towncity" value="<?=$towncity;?>" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>County:</strong> <input name="countystate" type="text" id="countystate" value="<?=$countystate;?>" /></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Postcode:</strong> <input name="postcodezip" type="text" id="postcodezip" value="<?=$postcodezip;?>" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>Country:</strong> <select name="country" value="<?=$scountry;?>" > <option value="United Kingdom" selected="selected">United Kingdom</option> <option value=""> - - - - - - - - - - </option> <option value="Other">Other</option> </select></p></td> </tr> </table> </fieldset></td> </tr> <tr> <td valign="top"> <p><fieldset><legend>Notes</legend> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center"><textarea name="notes" id="notes" class="notes"></textarea></td> </tr> <tr> <td width="50%" align="right" valign="top"><p class="form_details"><strong>Follow Up Date:</strong> <input name="followup" type="text" id="followup" size="25" /> <a href="javascript:NewCal('followup','yyyyMMdd')"><img src="date_picker/cal.gif" width="16" height="16" border="0" alt="Pick a date" /></a></p></td> <td width="50%" align="right" valign="top"> </td> </tr> </table> </fieldset></p> </table> <input name="send" type="submit" id="confirm_button" value="Submit" onsubmit="return validate_form(this)"> </form> </div> <div id="footer"><?php echo SITE_VERSION; ?></div> </div> </body> </html> <? } else { ?> <!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>Customer Management - Enter a new record</title> <link rel="stylesheet" type="text/css" href="styles/database.css"/> <link rel="icon" href="favicon.ico" type="image/x-icon"/> <script language="javascript" type="text/javascript" src="date_picker/datetimepicker.js"></script> </head> <body> <div id="wrapper"> <div id="header"></div> <div id="main_nav"> <?PHP include ("nav/main_nav.php"); ?> </div> <div id="main_content"> <h1>Please enter the customer details</h1> <form action="" method="post" onsubmit="return validate_form(this)"> <input name="form_set" type="hidden" value="true" /> <table width="700" border="0" cellpadding="0" cellspacing="0" id="data_container"> <tr> <td width="600" valign="top"><fieldset><legend>Company Details</legend> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="single_line_table"> <tr> <td width="50%" align="right" valign="middle"> <? if (empty($_POST['companyname'])) { echo $error_companyname; } ?> <? if (mysql_num_rows($company_name_result) > 0) { echo $error_companyname_taken; } ?> <p class="form_details"><strong>Company Name:</strong> <input name="companyname" type="text" id="companyname" tabindex="1" value="<? echo stripslashes($_POST['companyname']); ?>" /> <input type="hidden" name="companyname2" value="<? stripslashes($_POST['companyname']); ?>" /> </p> </td> <td width="50%" align="right" valign="middle"> <? if (empty($_POST['client_lead'])) { echo $error_booking_type; } ?><p class="form_details"><strong>Booking Type:</strong> <select name="client_lead" id="client_lead"> <option value="<? echo $_POST['client_lead']; ?>" selected="selected"><? if (empty($_POST['client_lead'])) { echo 'Please choose...'; } else if ($_POST['client_lead'] == 'C') { echo 'Client'; } else if ($_POST['client_lead'] == 'L') { echo 'Lead'; } ?></option> <option value="">-------------------</option> <? if (empty($_POST['client_type'])) { echo '<option value="C">Client</option><option value="L">Lead</option>'; } else if ($_POST['client_lead'] == 'C') { echo '<option value="L">Lead</option>'; } else if ($_POST['client_lead'] == 'L') { echo '<option value="C">Client</option>'; } ?> </select></p> </td> </tr> <tr> <td width="50%" align="right" valign="middle"> <? if (empty($_POST['clienttype'])) { echo $error_client_type; } ?><p class="form_details"><strong>Client Type:</strong> <select name="clienttype" id="clienttype" value=""> <option value="<? if (empty($_POST['clienttype'])) { echo ''; } else { echo $_POST['clienttype']; } ?>" selected="selected"><? if (empty($_POST['clienttype'])) { echo 'Please choose...'; } else { echo $_POST['clienttype']; } ?></option> <option value="">-------------------</option> <? // Populate the Advertiser Type drop down menu $sql = mysql_query("SELECT client_type_name FROM client_types"); $num = mysql_num_rows($sql); $i=0; while ($i < $num) { $item = mysql_result($sql,$i,"client_type_name"); $i++; echo '<option value="' . $item . '">' . $item . '</option>'; } ?> </select> </p> </td> <td width="50%" align="right" valign="middle"> <? if (empty($_POST['pre_payment'])) { echo $error_pre_payment; } ?><p class="form_details"><strong>Pre Payment:</strong> <select name="pre_payment" id="pre_payment" value="<?=$pre_payment;?>"> <option value="<? if (empty($_POST['pre_payment'])) { echo ''; } else { echo $_POST['pre_payment']; } ?>" selected="selected"><? if (empty($_POST['pre_payment'])) { echo 'Please choose...'; } else if ($_POST['pre_payment'] == 'Y') { echo 'Yes'; } else if ($_POST['pre_payment'] == 'N') { echo 'No'; } ?></option> <option value="">-------------------</option> <option value="Y">Yes</option> <option value="N">No</option> </select> </p> </td> </tr> <tr> <td width="50%" align="right" valign="middle"> <? if (empty($_POST['sales_contact'])) { echo $error_sales_contact; } ?><p class="form_details"><strong>Sales Contact:</strong> <select name="sales_contact" id="sales_contact"> <option value="<? if (empty($_POST['sales_contact'])) { echo ''; } else { echo $_POST['sales_contact']; } ?>" selected="selected"><? if (empty($_POST['sales_contact'])) { echo 'Please choose...'; } else { echo $_POST['sales_contact']; } ?></option> <option value="">------------------</option> <? // Populate the Section drop down menu $sql = mysql_query("SELECT * FROM users WHERE sales = 'Y'"); $num = mysql_num_rows($sql); $i=0; while ($i < $num) { $firstname = mysql_result($sql,$i,"firstname"); $lastname = mysql_result($sql,$i,"lastname"); $i++; echo '<option value="' . $firstname . ' ' . $lastname . '">' . $firstname . ' ' . $lastname . '</option>'; } ?> </select> </p></td> <td width="50%" align="right" valign="middle"><p class="form_details"><strong>Business Type:</strong> <input name="businesstype" type="text" id="businesstype" value="<? echo $_POST['businesstype']; ?>" tabindex="2" /> </p></td> </tr> <tr> <td width="50%" align="right" valign="middle"> <p class="form_details"><strong>Advertising In:</strong> <select name="advertisingin" id="advertisingin" value="<? echo $_POST['advertisingin']; ?>"> <option value="Wedding Ideas" selected="selected">Wedding Ideas</option> </select> </p></td> <td width="50%" align="right" valign="middle"><p class="form_details"> </p></td> </tr> </table> </fieldset> <tr> <td valign="top"><fieldset><legend>Contact Details</legend> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="single_line_table"> <tr> <td width="50%" align="right"> <? if (empty($_POST['contactonefirstname'])) { echo $error_contact_one_first_name; } ?><p class="form_details"><strong>(1) First Name:</strong> <input name="contactonefirstname" type="text" id="contactonefirstname" value="<? echo $_POST['contactonefirstname']; ?>" tabindex="3" /></p> </td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>(2) First Name:</strong> <input name="contacttwofirstname" type="text" id="contacttwofirstname" value="<? echo $_POST['contacttwofirstname']; ?>"tabindex="6" /></p> </td> </tr> <tr> <td width="50%" align="right"> <? if (empty($_POST['contactonelastname'])) { echo $error_contact_one_last_name; } ?><p class="form_details"><strong>(1) Last Name:</strong> <input name="contactonelastname" type="text" id="contactonelastname" value="<? echo $_POST['contactonelastname']; ?>" tabindex="4" /></p> </td> <td width="50%" align="right" valign="top"> <p class="form_details"><strong>(2) Last Name:</strong> <input name="contacttwolastname" type="text" id="contacttwolastname" value="<? echo $_POST['contacttwolastname']; ?>" tabindex="7" /></p> </td> </tr> <tr> <td width="50%" align="right"> <? if (empty($_POST['contactoneemail'])) { echo $error_contact_one_email; } ?><p class="form_details"><strong>(1) E-mail:</strong> <input type="text" name="contactoneemail" id="contactoneemail" value="<? echo $_POST['contactoneemail']; ?>" tabindex="5" /></p> </td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>(2) E-mail:</strong> <input type="text" name="contacttwoemail" id="contacttwoemail" value="<? echo $_POST['contacttwoemail']; ?>" tabindex="8" /></p></td> </tr> <tr> <td width="50%" align="right"> <p class="form_details"><strong>Website:</strong> <input name="website" type="text" id="website" value="<? echo $_POST['website']; ?>" tabindex="9" /></p> </td> <td width="50%" align="right" valign="top"> </td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Phone:</strong> <input name="phone" type="text" id="phone" value="<? echo $_POST['phone']; ?>" tabindex="10" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>Fax:</strong> <input type="text" name="fax" id="fax" value="<? echo $_POST['fax']; ?>" tabindex="11"/></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Mobile:</strong> <input type="text" name="mobile" id="mobile" value="<? echo $_POST['mobile']; ?>" tabindex="11" /></p></td> <td width="50%" align="right" valign="top"> </td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Address:</strong> <input name="address" type="text" id="address" value="<? echo $_POST['address']; ?>" tabindex="12" /></p></td> <td width="50%" align="right" valign="top"> </td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Town/City:</strong> <input name="towncity" type="text" id="towncity" value="<? echo $_POST['towncity']; ?>" tabindex="13" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>County:</strong> <input name="countystate" type="text" id="countystate" value="<? echo $_POST['countystate']; ?>" tabindex="14" /></p></td> </tr> <tr> <td width="50%" align="right"><p class="form_details"><strong>Postcode:</strong> <input name="postcodezip" type="text" id="postcodezip" value="<? echo $_POST['postcodezip']; ?>" tabindex="15" /></p></td> <td width="50%" align="right" valign="top"><p class="form_details"><strong>Country:</strong> <select name="country"> <option value="United Kingdom" selected="selected">United Kingdom</option> <option value=""> - - - - - - - - - - </option> <option value="Other">Other</option> </select></p></td> </tr> </table> </fieldset></td> </tr> <tr> <td valign="top"> <p><fieldset><legend>Notes</legend> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" align="center"><textarea name="notes" id="notes" class="notes" tabindex="16" ><? echo $_POST['notes']; ?></textarea></td> </tr> <tr> <td width="50%" align="right" valign="top"><p class="form_details"><strong>Follow Up Date:</strong> <input name="followup" type="text" id="followup" size="25" tabindex="17" value="<? echo $_POST['followup']; ?>" /> <a href="javascript:NewCal('followup','yyyyMMdd')"><img src="date_picker/cal.gif" width="16" height="16" border="0" alt="Pick a date" /></a></p></td> <td width="50%" align="right" valign="top"> </td> </tr> </table> </fieldset></p> </table> <input name="send" type="submit" id="confirm_button" value="Submit" onsubmit="return validate_form(this)"> </form> </div> <div id="footer"><?php echo SITE_VERSION; ?></div> </div> </body> </html> <? } ?>
  23. Hi can anyone help me format this array. I've got... 7, 8.4 | 11, 8.4 | 7, 8.4 | 16, 8.4 | 18, 12.6 So that it reads (7 x 8.4) + (11 x 8.4) + (7 x 8.4) + (16 x 8.4) + (18 x 12.6) and then add the total (presumably using array_sum) I'm in desperate need to get this done so any help would be great! Thanks James
  24. Managed to sort it by using SUM() in my mysql query. Didn't even know it existed! James
×
×
  • 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.