Jump to content

wright67uk

Members
  • Posts

    454
  • Joined

  • Last visited

Everything posted by wright67uk

  1. As you will see below, I have a php file with loads of repeating code. Is there a way I can simplify my script a little. Im not an advanced user but I was thinking somwhere along the lines of, having the 'type' in my sql query as an array so that the type would change after each query. What would you reccommend. I think my code looks like its wasting a lot of space. <?php include($_SERVER['DOCUMENT_ROOT'].'/include/db.php'); ?> <title>Untitled Document</title> <style type="text/css"> <!-- --> </style> <link href="header.css" rel="stylesheet" type="text/css" /> <link href="a.css" rel="stylesheet" type="text/css" /> </head><body> <div id="bodywrap"> <div id="banner"> <div id="bannerleft"></div> <div id="logo"><img src="i-stevenage.png" height="100%" width="100%" alt="I-stevenage"/></div> <div id="bannerright"><div id="navbar" title=""> <div id="b1"><p class="centre"><a href="index.html">Directory</a></p></div> <div id="b2"><p class="centre"><a href="business.html">Add Your Business</a></p></div> <div id="b3"><p class="centre"><a href="contact.html">Contact Us</a></p></div> </div><!-- end of navbar--> </div><!--end of bannerright--> </div><!-- end of banner--> <div id="wrapper"> <div id="listhold"> <!-- Next Catergory --> <div class="list"><h1>Cars and Travel</h1> <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Cars and Travel' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Legal</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Legal' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Retail</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Retail' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Hygene</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Hygene' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Refuse</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Refuse' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div><!--end of list --> <!-----------------------------------------------------------------------------------------------------------------------------------------------------> <!-----------------------------------------------------------------------------------------------------------------------------------------------------> <!-- Next Catergory --> <div class="list"><h1>Skilled Trades</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Skilled Trades' AND confirmed ='Yes' ORDER BY subtype"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach ($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div><!--end of list--> <!-----------------------------------------------------------------------------------------------------------------------------------------------------> <!-----------------------------------------------------------------------------------------------------------------------------------------------------> <!-- next catergory --> <div class="list"> <h1>Care</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Care' AND confirmed ='Yes' ORDER BY subtype"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach ($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Education</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='education' AND confirmed ='Yes' ORDER BY subtype"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach ($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Financial</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='financial' AND confirmed ='Yes' ORDER BY subtype"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach ($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Home and Garden</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='home and garden' AND confirmed ='Yes' ORDER BY subtype"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach ($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Wellbeing</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Wellbeing' AND confirmed ='Yes' ORDER BY subtype"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach ($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?>
  2. Say for example I have three divs. Each of the divs 300px wide, all floating next to each other in a parent div (900px wide). Can I get these divs to stack on top of each other, if sombody reduces the window size of my site?
  3. Hello, ive been asked to design a site by a local tree surgery company. The company have said they want somthing presentable, but other than that no-one want to meet me to look at any wireframes, color boards etc. etc. So here goes... www.1pw.co.uk , love to know what you think. Presentable, Ugly, messy, smart etc.
  4. Im using a background image in my #Logo div. If i minimise my browser window #bannerright will overlap my image. I dont want this to happen as the image is a logo that needs to be displayed all of the time. Is my only way around this to place the image in my html opposed to as a bg image in my css? What is the usual practice when you want a website to look good in different monitor/browser sizes? Ive used a 100% width in my banner as I want it to span the whole screen at all times, however things such as my google map have fixed widths. Should I be combining % in one part of my page and then px in another. Please any suggestions. I have a test page www.1pw.co.uk/b.php. Any suggestions /constructive critisism welcome. Many thanks from an amateur wanting to learn. <!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" /> <link href="header.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="banner"> <div id="bannerleft"></div> <div id="logo"></div> <div id="bannerright"><div id="navbar" title=""> <div id="b1"><p class="centre"><a href="index.html">Directory</a></p></div> <div id="b2"><p class="centre"><a href="business.html">Add Your Business</a></p></div> <div id="b3"><p class="centre"><a href="contact.html">Contact Us</a></p></div> </div><!-- end of navbar--> </div><!--end of bannerright--> </div><!-- end of banner--> @charset "utf-8"; /* CSS Document */ body { color:#FFF; font-family:Tahoma, Geneva, sans-serif; } #listhold { width:1000px; height:auto; margin-left:auto; margin-right:auto; margin-top:20px; background-color:#06F; padding-left:10px; } #b1 {margin-right:70px; margin-left:70px; height:40px; float:left} #b2 {margin-right:70px; height:40px; float:left} #b3 {margin-right:70px; height:40px; float:left} a:link {color: #FFF;text-decoration: none;} a:visited {text-decoration: none;color: #FFF;} a:hover {text-decoration: none;color: #CCC;} a:active {text-decoration: none;color: #CCC;} a.blue {color:#06F;} p.centre {color:#FFF; margin-top:2px; text-align:center;} #banner { height:80px; width:100%; margin-top:30px; } #bannerleft { background-color:#36F; height:25px; width:10%; float:left; margin-top:13px; } #logo { height:80px; width:22%; background-image:url(i-stevenage.png); background-repeat:no-repeat; float:left; overflow:visible; } #bannerright { background-color:#36F; height:25px; width:68%; float:left; margin-top:13px; }
  5. Hi im trying to get name, phone, email, webaddress into POST variables, but only my postcode variable is being carried in my url, can anybody help me please? <?php $subtype = $_GET['subtype']; $subtype = ucwords (strtolower($subtype)); echo "<h1>$subtype</h1>"; $query = "SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name"; if( $result = mysql_query($query) ) { echo mysql_error(); while($row = mysql_fetch_assoc($result) ) { foreach( $row as $k => $v ) { if( empty($v) ) { unset($row[$k]); } } if( !empty($row['postcode']) ) { $row['postcode_link'] = "<p class=link><a href='/gmap.php? phone=" . urlencode($row['phone']) . " &email=" . urlencode($row['email']) . " &webaddress=" . urlencode($row['webaddress']) . " &postcode=" . urlencode($row['postcode']) . "'>Map</a></p><br>"; } echo implode( '<br>', $row); } } ?>
  6. Thankyou for the suggestions. Is there a third person that would like to confirm which of these ways is using the best practice?
  7. Have you spoken to your host? What mhost do you use? Have you tried using no port no. and leaving it to default? - (godaddy)
  8. Is there a way to add to this script so that 'name', 'phone' , 'email' and 'webaddress' are also variables. Im looking to put the variables into the gmap.php link below. <?php $subtype = $_GET['subtype']; $subtype = ucwords (strtolower($subtype)); echo "<h1>$subtype</h1>"; $query = "SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name"; if( $result = mysql_query($query) ) { echo mysql_error(); while($row = mysql_fetch_assoc($result) ) { foreach( $row as $k => $v ) { if( empty($v) ) { unset($row[$k]); } } if( !empty($row['postcode']) ) { $row['postcode_link'] = "<p class=link><a href='/gmap.php?postcode=" . urlencode($row['postcode']) . "'>Map</a></p><br>"; } echo implode( '<br>', $row); } } ?>
  9. Im trying to place the corresponding name, telephone, and email address of my query from header.php into gmap.php. I pressume that I need to post the variables into; <a href='/gmap.php?postcode=" . urlencode($row['postcode']) . "'> (header.php) and then GET them in gmap.php How can I pull name, telephone and email from the query in header.php and turn them into variables? gmap.php <div id="listhold"> <?php $postcode = $_GET["postcode"]; $zoom = 15; echo "<img src='http://maps.google.com/maps/api/staticmap?zoom=$zoom&size=400x400&markers=color:blue|label:EXAMPLE|$postcode&sensor=false' class='default'/>"; ?> </div> <div id="boxright"> <!--id like to echo name, telephone, email here--> </div> header.php <?php $subtype = $_GET['subtype']; $subtype = ucwords (strtolower($subtype)); echo "<h1>$subtype</h1>"; $query = "SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name"; if( $result = mysql_query($query) ) { echo mysql_error(); while($row = mysql_fetch_assoc($result) ) { foreach( $row as $k => $v ) { if( empty($v) ) { unset($row[$k]); } } if( !empty($row['postcode']) ) { $row['postcode_link'] = "<p class=link><a href='/gmap.php?postcode=" . urlencode($row['postcode']) . "'>Map</a></p><br>"; } echo implode( '<br>', $row); } } ?> b.php <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Cars and Travel' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> <h1>Legal</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Legal' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . ucwords(strtolower (($nt[$i]))) . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?>
  10. Hello, im looking to return all of my sql results in proper case / first letter capitalised. I see from the manual you can use <?php $variable1 = 'my non capitalised text here'; $variable1 = ucwords($variable1); echo $variable1; // now my text reads My Non Capitalised Text Here ?> How can I apply somthing like the above to the results of my query without effecting the rest of my script? Is it the case of doing somthing like; $query = ucwords($query); <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Accommodation' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?>
  11. Thankyou, that is great to know. I do need to change the values to First Letter Capitals but I wasn't too sure if it was possible within mysql. <?php $subtype = $_GET['subtype']; echo "<h1>$subtype</h1>"; $query = "SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name"; if( $result = mysql_query($query) ) { echo mysql_error(); while($row = mysql_fetch_assoc($result) ) { foreach( $row as $k => $v ) { if( empty($v) ) { unset($row[$k]); } } if( !empty($row['postcode']) ) { $row['postcode_link'] = "<p class=link><a href='/gmap.php?postcode=" . urlencode($row['postcode']) . "'>Map</a></p><br>"; } echo implode( '<br>', $row); } } ?> The results in the query above would be using the first letter capitals. Im not bothered if this is stored in mysql or wether it is just formartted in php, just a bit gazumped when it comes to doing it.
  12. Is there a way to change all of my values within a mysql table to proper case? At the moment I have some values as upper and others as lower. I have mysql admin. Is this possible, or would it be easier to transfer my data into excel for processing?
  13. Thankyou very much, that worked well first time. Any chance you could talk through; foreach( $row as $k => $v ) {if( empty($v) ) {unset($row[$k]);} what is actually happening here. I feel a bit cheeky using your code and not learning what its doing!
  14. Hello, Im sure this is an easy one, but I just cant get my head around this. Where my results are displayed and there is a result without a webaddress or email address, I dont want "br" to be output. I pressume I need an If / else if statement for $row, but Im unsure of how I would incorporate this into my array? and im also unsure of how to say IF $row == NULL, - dont display anything. <?php $subtype = $_GET['subtype']; echo "<h1>$subtype</h1>"; $result = mysql_query("SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($row = mysql_fetch_array($result)) { echo $row['name'] . "<br>"; echo $row ['phone'] . "<br>"; echo $row['email'] . "<br>"; echo $row['WebAddress'] . "<br>"; echo $row['postcode'] ; $postcode = str_replace(' ','+',$row['postcode']); echo "<p class=link><a href='/gmap.php?postcode=$postcode'>Map</a></p><br>"; } ?>
  15. Hello. Ive added a tickbox to my code below, and now I get errors returned, Parse error: syntax error, unexpected T_LOGICAL_OR I know that this is relation to; <?php elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) or $Tickbox == ("!True"); { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } ?> Im just unsure of how to write the aditional tickbox validation into my script. I either want a correctly written website address to be submitted OR for the customer to tick a box saying they dont have one. Please can anybody help me? <form name="add" action="#" method="post"> <fieldset> <legend>Add Your Business</legend> <p><label for="Name">Name</label><input type="text" name="Name" id="Name" maxlength="50" value=" <?php $Name = $_POST['Name']; if (!empty($Name)) echo $Name; ?>"/></p> <p><label for="Phone">Phone</label> <input type="text" name="Phone" id="Phone" maxlength="50" value=" <?php $Phone = $_POST['Phone']; if (!empty($Phone)) echo $Phone; ?>"/></p> <p><label for="Email">Email</label><input type="text" name="Email" id="Email" maxlength="50" value=" <?php $Email = $_POST['Email'];if (!empty($Email)) echo $Email; ?>" /></p> <p><label for="Postcode">Postcode</label><input type="text" name="Postcode" id="Postcode" maxlength="50" value=" <?php $Postcode = $_POST['Postcode']; if (!empty($Postcode)) echo $Postcode; ?>"/></p> <p><label for="Web Address">Web Address</label><input type="text" name="Website" id="Website" maxlength="50" value=" <?php $Website = $_POST['Website']; if (!empty($Website)) echo $Website; ?>"/> <label for="Web Tick">I dont have a website</label><input type="checkbox" name="Tickbox" id="Tickbox" value="True" /></p> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> <br /> </fieldset> </form> <div id="results"> <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); $Tickbox = mysql_real_escape_string($_POST["Tickbox"]); if($Name == '') { die ("<div class=\"form\">You did not complete the name field, please try again</div>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die("<div class=\"form\"> You completed the telephone field incorrectly, please try again</div>"); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die("<div class=\"form\"> You completed the Email field incorrectly, please try again</div>"); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die("<div class=\"form\"> You did not complete the Postcode field correctly, please try again</div>"); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) or $Tickbox == ("!True"); { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } else { echo("<div id=\"formtwo\">Thankyou for submiting your details, you will be added to our directory shortly</div>"); } $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`, `confirmed`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website', 'Yes')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); } ?>
  16. Apologies as I didint mean to submit just yet. I'd like to add a checkbox into my form below, for any customers that don't have websites. Im not sure of the best way to do this or the correct syntax. Maybe somthing like; <p><label for="Web Address">Web Address</label><input type="text" name="Website" id="Website" maxlength="50" value=" <?php $Website = $_POST['Website']; if (!empty($Website)) echo $Website; ?>"/></p> <p>If you dont have a website please click here</p><input type="checkbox" name="website" value="true" /> --------------------------------------------------------------------------------------------------------------------------------------------------------------------- elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) else(isset($_POST['website']) && $_POST['website'] == 'true') { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); }
  17. <form name="add" action="#" method="post"><fieldset><legend>Add Your Business</legend> <p><label for="Name">Name</label><input type="text" name="Name" id="Name" maxlength="50" value=" <?php $Name = $_POST['Name']; if (!empty($Name)) echo $Name; ?>"/></p> <p><label for="Phone">Phone</label> <input type="text" name="Phone" id="Phone" maxlength="50" value=" <?php $Phone = $_POST['Phone']; if (!empty($Phone)) echo $Phone; ?>"/></p> <p><label for="Email">Email</label><input type="text" name="Email" id="Email" maxlength="50" value=" <?php $Email = $_POST['Email']; if (!empty($Email)) echo $Email; ?>" /></p> <p><label for="Postcode">Postcode</label><input type="text" name="Postcode" id="Postcode" maxlength="50" value=" <?php $Postcode = $_POST['Postcode']; if (!empty($Postcode)) echo $Postcode; ?>"/></p> <p><label for="Web Address">Web Address</label><input type="text" name="Website" id="Website" maxlength="50" value=" <?php $Website = $_POST['Website']; if (!empty($Website)) echo $Website; ?>"/></p> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"><img alt="Please Wait" src="ajax-loader.gif"/></span> <span id="result_1" style="display: none;"></span><br /> </fieldset></form> <div id="results"> <?php function checkPostcode (&$toCheck) { $alpha1 = "[abcdefghijklmnoprstuwyz]"; $alpha2 = "[abcdefghklmnopqrstuvwxy]"; $alpha3 = "[abcdefghjkstuw]"; $alpha4 = "[abehmnprvwxy]"; $alpha5 = "[abdefghjlnpqrstuwxyz]"; $pcexp[0] = '^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[1] = '^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([0-9]{1}'.$alpha5.'{2})$'; $pcexp[2] = '^('.$alpha1.'{1}'.$alpha2.'[0-9]{1}'.$alpha4.')([0-9]{1}'.$alpha5.'{2})$'; $pcexp[3] = '^(gir)(0aa)$'; $pcexp[4] = '^(bfpo)([0-9]{1,4})$'; $pcexp[5] = '^(bfpo)(c\/o[0-9]{1,3})$'; $Postcode = strtolower($toCheck); $Postcode = str_replace (' ', '', $Postcode); $valid = false; foreach ($pcexp as $regexp) { if (ereg($regexp,$Postcode, $matches)) { $toCheck = strtoupper ($matches[1] . ' ' . $matches [2]); $toCheck = ereg_replace ('C\/O', 'c/o ', $toCheck); $valid = true; break; } } if ($valid){return true;} else {return false;}; } if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { /* foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } */ die ("<div class=\"form\">You did not complete the name field, please try again</div>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die("<div class=\"form\"> You completed the telephone field incorrectly, please try again</div>"); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die("<div class=\"form\"> You completed the Email field incorrectly, please try again</div>"); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die("<div class=\"form\"> You did not complete the Postcode field correctly, please try again</div>"); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) //add tickbox here { die("<div class=\"form\">You completed the website field incorrectly, please try again</div>"); } else { echo("<div id=\"formtwo\">Thankyou for submiting your details, you will be added to our directory shortly</div>"); } $query = ("INSERT INTO business (`id`, `Name`, `Type`, `Subtype`, `Phone`, `Email`, `Postcode`, `WebAddress`, `confirmed`) VALUES ('NULL', '$Name', '$drop', '$tier_two' , '$Phone', '$Email', '$Postcode', '$Website', 'Yes')"); mysql_query($query) or die ( "<br>Query: $query<br>Error: " .mysql_error()); } ?>
  18. I have tried; echo <a href="http://maps.google.com/maps/api/staticmap?zoom=15&size=400x400&markers=color:blue|label:EXAMPLE|. str_replace(' ','+',$row['postcode'])&sensor=false">; but then I get unexpected '<' ... error
  19. and in this case as I have several lines of my code in red, im asking if anyone can help me. Please.
  20. Can anybody help me to echo a url? Id like to have http://maps.google.com/maps/api/staticmap?zoom=15&size=400x400&markers=color:blue|label:EXAMPLE|SG1+4PP&sensor=false but to have the postcode as a variable which has been fetched from mysql <!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> <?php include($_SERVER['DOCUMENT_ROOT'].'/include/db.php'); ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- --> </style> <link href="header.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="banner"> <div id="bannerleft"></div> <div id="logo"></div> <div id="bannerright"><div id="navbar" title=""> <div id="b1"><p class="centre"><a href="index.html">Directory</a></p></div> <div id="b2"><p class="centre"><a href="business.html">Add Your Business</a></p></div> <div id="b3"><p class="centre"><a href="contact.html">Contact Us</a></p></div> </div><!-- end of navbar--> </div><!--end of bannerright--> </div><!-- end of banner--> <div id="listhold"> <?php $subtype = $_GET['subtype']; echo "<h1>$subtype</h1>"; $result = mysql_query("SELECT name, phone, email, WebAddress, postcode FROM business WHERE subtype ='$subtype' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($row = mysql_fetch_array($result)) { echo $row['name'] . "<br>"; echo $row ['phone'] . "<br>"; echo $row['email'] . "<br>"; echo $row['WebAddress'] . "<br>"; echo $row['postcode'] . "<br>" . "<br>"; echo "<a href='http://maps.google.com/maps/api/staticmap?zoom=15&size=400x400&markers=color:blue|label:EXAMPLE|.str_replace(' ','+',$row['postcode'])&sensor=false'>"; } ?> </div> </body> </html> The above returns an error; Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
  21. Im trying to get everything in and within my wrapper div to have a blue background. Unfortunately .list exposes a white background where its margins are. see (www.1pw.co.uk/b.php) Any way around this? You can preview this file in IE, however firefox seems to hate me and my site. More work to do I guess. a.css @charset "utf-8"; body { color:#06F; } h1 { color:#FFF; font-size:18px; padding-bottom:0px; margin-bottom:3px } input { color: #781351; background: #B9E7FF; border: 1px solid #06C } .submit input { color: #000; background: #ffa20f; border: 2px outset #d7b9c9 } form#add { background-color: #cccccc; color: #F00; border: 1px solid #999999; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 18px; text-align: right; } .list { width:230px; margin-left:20px; color:#FFF; height:auto; float:left; background-color:#06F } #listhold { width:1000px; height:auto; margin-left:auto; margin-right:auto; margin-top:20px; background-color:#06F } a:link { color: #FFF; text-decoration:none } a:visited { color: #FFF; text-decoration:none } a:hover { color: #FFF; text-decoration:none } a:active { color: #FFF; text-decoration:none } #wrapper { background-color:#06f; height:auto; width:auto } <!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" /> <!--ADD TAKEAWAYS TYPE AND SOME SUBTYPES --> <?php include($_SERVER['DOCUMENT_ROOT'].'/include/db.php'); ?> <title>Untitled Document</title> <style type="text/css"> <!-- --> </style> <link href="a.css" rel="stylesheet" type="text/css" /> <link href="newbusiness.css" rel="stylesheet" type="text/css" /> </head><body> <div id="banner"> <div id="bannerleft"></div> <div id="logo"></div> <div id="bannerright"><div id="navbar" title=""> <div id="b1"><p class="centre"><a href="index.html">Directory</a></p></div> <div id="b2"><p class="centre"><a href="business.html">Add Your Business</a></p></div> <div id="b3"><p class="centre"><a href="contact.html">Contact Us</a></p></div> </div><!-- end of navbar--> </div><!--end of bannerright--> </div><!-- end of banner--> <div id="wrapper"> <div id="listhold"> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><h1>Places To Stay</h1> <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Accommodation' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><h1>Eating Out</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><h1>Eating In</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Takeaways' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------SKILLED TRADES BELOW---------------------------------------------------> <div class="list"><h1>Skilled Trades</h1> <?php $nt = array(); $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Skilled Trades' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><a href="Hotels.html"></a> </div> <!------------------------------------------------------------------------------- -------------------------------------------------> <div class="list"><a href="Electricians.html"></a><br /></div> <div class="list"><a href="Gardeners.html"></a><br/></div> <div class="list"><a href="More.html"></a><br/></div> </div><!--end div list hold--> </div><!--end of wrapper--> </body> </html> These css properties are used mainly for other pages, but I thought Id include them here just in case. newbusiness.css @charset "utf-8"; #b1 {margin-right:70px; margin-left:70px; height:40px; float:left} #b2 {margin-right:70px; height:40px; float:left} #b3 {margin-right:70px; height:40px; float:left} a:link {color: #FFF;text-decoration: none;} a:visited {text-decoration: none;color: #FFF;} a:hover {text-decoration: none;color: #CCC;} a:active {text-decoration: none;color: #CCC;} a.blue {color:#06F;} p.centre {color:#FFF; margin-top:2px; text-align:center;} #banner { height:80px; width:100%; margin-top:30px; } #bannerleft { background-color:#36F; height:25px; width:10%; float:left; margin-top:13px; } #logo { height:80px; width:22%; background-image:url(i-stevenage.png); background-repeat:no-repeat; float:left; } #bannerright { background-color:#36F; height:25px; width:68%; float:left; margin-top:13px; } form { margin-left:405px; margin-top:80px; clear:both; } .form { color:#F00; height:100px; width:700px; margin-left:100px; clear:both; } #formtwo { color:#666; height:100px; width:700px; margin-left:100px; } #results { margin-left:300px; } body { font-family:Tahoma, Geneva, sans-serif; font-size:16px; color:#252525; } P.form { color:#FF03; margin-left:100px; text-align:left; clear:both; } P.passed { color:#333; margin-left:100px; text-align:left; clear:both; } label { width: 6em; float: left; text-align: right; margin-right: 0.5em; display: block; } .submit input { margin-left: 4.5em; } input { color: #333; background: #D9FCFF; border: 1px solid #06F; } .submit input { color: #000; background: #ffa20f; border: 2px outset #d7b9c9; } fieldset { border: 1px solid #06F; width: 20em; } legend { color: #fff; background:#0073FF; border: 1px solid #781351; padding: 2px 6px; } Many thanks
  22. How shouold I go about reseting $nt, Im still learning php, I thought that my new mysql statements would give $nt new values?
  23. What would be the correct way to close a mysql query? At current the second query below returns results from the 1st query AND the 2nd query The 3rd query returns results from the 1st, 2nd and 3rd query. etc etc. At the moment I get somthing returned along the lines of... QUERY 1 RESULTS Accommodation 1 Accommodation 2 Accommodation 3 QUERY 2 RESULTS Restaurant 1 Restaurant 2 Restaurant 3 Accommodation 1 Accommodation 2 Accommodation 3 QUERY 3 RESULTS Takeaways 1 Takeaways 2 Takeaways 3 Restaurant 1 Restaurant 2 Restaurant 3 Accommodation 1 Accommodation 2 Accommodation 3 <!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" /> <?php include($_SERVER['DOCUMENT_ROOT'].'/include/db.php'); ?> <title>Untitled Document</title> <style type="text/css"> <!-- --> </style> <link href="a.css" rel="stylesheet" type="text/css" /> </head><body> <div id="listhold"> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><a href="Placestostay.html">Places To Stay</a><br /> <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Accommodation' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><a href="Eatingout.html">Eating Out</a><br /> <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------------------------------------------------------------------------------> <div class="list"><a href="Eatingin.html">Eating In</a><br /> <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Takeaways' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div> <!------------------------------------------------------------------------------SKILLED TRADES BELOW---------------------------------------------------> <div class="list"><a href="Skilledtrades.html">Skilled Trades</a><br/> <?php $title ="TITLE GOES HERE"; $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Skilled Trades' AND confirmed ='Yes' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; $FileName = str_replace(' ','_',$nt[$i]) . ".php"; $FileUsed = str_replace('_',' ',$nt[$i]); echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".php?title=$title&subtype=$FileUsed'>" . $nt[$i] . "</a>" . "<br/>"; $FileHandle = fopen($FileName, 'w') or die("cant open file"); $pageContents = file_get_contents("header.php"); fwrite($FileHandle,"$pageContents");} fclose($FileHandle); ?> </div>
  24. <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '') { ....... ?> Could I remove this code and use the below code and still have the same effect? <?php if(isset($_POST['submit'])) { foreach ($_POST as $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } ?>
  25. I put an example of include above, maybe you could use include and post some variables; includename.php?variable=$variable&variable2=$variable2 Why did you say you didnt want to use include?
×
×
  • 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.