Jump to content

dthomas31uk

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dthomas31uk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. change the table??? Why?? have a dbase called eu_place and in that have country, city... Not sure why. Can you advise
  2. Hi. have a page that allows a user to select a country and from that show the cities in that country, but the problem I have is that when I have more than one city for a particular country the country drop down list shows numerous countries of the same country. Its probably better to see what I am on about by giving you a link to the page http://www.gostoke.eu/eu_home.php Here is the code that I have. Hope someone can help. Thanks //@$cat=$_GET['cat']; // Use this line or below line if register_global is off @$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off ///////// Getting the data from Mysql table for Pick Up list box////////// $querPick=mysql_query("SELECT city, id FROM uk_place"); if (!$querPick) { exit('<p>Unable to obtain category list from the ' . 'database.</p>'); } ///////////// End of query for first list box//////////// ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT country,id FROM eu_place order by country"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT city FROM eu_place where id=$cat order by city"); }else{$quer=mysql_query("SELECT DISTINCT city FROM eu_place order by city"); } ////////// end of query for second subcategory drop down list box /////////////////////////// /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// print 'Select country destination:'; echo "<select class='countrydrop' name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; echo mysql_error(); while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['id']==@$cat){echo "<option selected value='$noticia2[id]'>$noticia2[country]</option>"."<BR>";} else{echo "<option value='$noticia2[id]'>$noticia2[country]</option>";} } echo "</select>"."<BR>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// print 'Select city destination:'; echo "<select class='citydrop' name='subcat'><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { echo "<option value='$noticia[city]'>$noticia[city]</option>"; } echo "</select>"."<BR>";
  3. I have a web page that I have created that allows a user to select info from database http://www.gostoke.eu/eu_home.php When the submit button is pressed the results are shown on the same page, but what I want to do is to display the results on a new page. Can anyone help??? Here is the code that handles the form information <?php include 'eu_home.php'; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Demo Multiple drop down list box from plus2net</title> </head> <body> <?php $pickup=$_POST['pickup']; $cat=$_POST['cat']; $subcat=$_POST['subcat']; $load=$_POST['load']; $appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy echo "Date required $appointment_date"."<BR>"; echo "Picking up from $pickup" ."<BR>"; echo "Going to $subcat"."<BR>"; $result = mysql_query("SELECT full_price, half_price, luton FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error()); $row = mysql_fetch_array($result); switch($load) { case 'full_load' : $total = $row['full_price']; break; case 'half_load' : $total = $row['half_price']; break; case 'luton': $total = $row['luton']; break; } $rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC)) { $iPrice = $aRow['price']; echo "£"; echo ($iPrice) + ($total)."<BR>"; } echo "<form method=post name=f2 action='confirm.php'>"; echo 'To confirm the above details, please enter your details below and click submit' . "<br />"; echo 'Full Name' . "<input type='text' name='name' id='name'/>" . "<br />"; echo 'Telephone Number' . "<input type='text' name='telephone' id='telephone'/>" . "<br />"; echo 'Email' . "<input type='text' name='email' id='email'/>" . "<br />"; echo 'Comments:' ."<textarea id='textareainput' name='textareainput' rows='10' cols='22'></textarea>"; echo "<input type='hidden' name='date' id='date' value='$appointment_date'/>"; echo "<input type='hidden' name='pickUpPoint' id='pickUpPoint' value='$pickup'/>"; echo "<input type='hidden' name='destination' id='destination' value='$subcat'/>"; echo "<input type='hidden' name='loadType' id='loadType' value='$load'/>"; echo "<input type='hidden' name='price' id='price' value='($iPrice) + ($total)'/>" . "<br />"; echo "<input type=submit value=Confirm>"; ?> </div> </body> </html>
  4. Have managed to get it sorted, was this line of code here.... self.location='dd.php?cat=' + val ; Thanks Anyways
  5. Its all uploaded online fine its when you go to select a country from the first drop down box. You select the country and as soon as you select it you get a 4o4 error page not found. This is the page its looking for http://www.gostoke.eu/dd.php?cat=1 This all works fine on my localhost ???
  6. Hi. Have developed a form that connects with my database using PHP. All of it works great on my localhost, but when I have uploaded it to my server it aint doing the same thing. First off you select the date, thats ok, then you select a country from the drop down list it sees the countries in the database, but when you select it from the drop down list is cannot locate it and comes up with page not found error. Any ideas what I am doing wrong guys. Here is a link to the page concerned online http://www.gostoke.eu/eu_home.php And here is the php in the eu_home.php page <?php $dbservertype='mysql'; $servername='localhost'; // username and password to log onto db server $dbusername='**********'; $dbpassword='*********'; // name of database $dbname='dthomas_europe'; //////////////////////////////////////// ////// DONOT EDIT BELOW ///////// /////////////////////////////////////// connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } //////// End of connecting to database //////// ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Multiple drop down list box from plus2net</title> <SCRIPT language=JavaScript> function reload(form) { var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='dd.php?cat=' + val ; } </script> </head> <body> <form method=post name=f1 action='dd-check.php'> <select name = 'day' class="listBox" tabindex="4" > <?php // generate day numbers for ($x = 1; $x <= 31; $x++) { echo "<option value = $x>$x</option>"; } ?> </select> <select name = 'month' class="listBox" tabindex="4" > <?php // generate month names for ($x = 1; $x <= 12; $x++) { echo "<option value=$x>".date('F', mktime(0, 0, 0, $x, 1, 1)).'</option>'; } ?> </select> <select name = 'year' class="listBox" tabindex="4" > <?php // generate year values for ($x = 2007; $x <= 2008; $x++) { echo "<option value=$x>$x</option>"; } ?> </select> <br /> <? /* If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care. To read more on register_global visit. http://www.plus2net.com/php_tutorial/register-globals.php */ //@$cat=$_GET['cat']; // Use this line or below line if register_global is off @$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off ///////// Getting the data from Mysql table for Pick Up list box////////// $querPick=mysql_query("SELECT city, id FROM uk_place"); if (!$querPick) { exit('<p>Unable to obtain category list from the ' . 'database.</p>'); } ///////////// End of query for first list box//////////// ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT country,id FROM eu_place order by country"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT city FROM eu_place where id=$cat order by city"); }else{$quer=mysql_query("SELECT DISTINCT city FROM eu_place order by city"); } ////////// end of query for second subcategory drop down list box /////////////////////////// /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; echo mysql_error(); while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['id']==@$cat){echo "<option selected value='$noticia2[id]'>$noticia2[country]</option>"."<BR>";} else{echo "<option value='$noticia2[id]'>$noticia2[country]</option>";} } echo "</select>"."<BR>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat'><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { echo "<option value='$noticia[city]'>$noticia[city]</option>"; } echo "</select>"."<BR>"; ////////////////// This will end the second drop down list /////////// echo 'Load from 14m3 - 20m3' . "<label><input type='radio' name='load' value='luton'</label>"."<BR>"; echo 'Load from 7m3 - 14m3'."<label><input type='radio' name='load' value='full_load'</label>"."<BR>"; echo 'Load from 1m3 - 7m3' . "<label><input type='radio' name='load' value='half_load'</label>"."<BR>"; ////////// Starting of second drop downlist ///////// echo "<select name='pickup'><option value=''>Select one</option>"; while($pickup = mysql_fetch_array($querPick)) { echo "<option value='$pickup[city]'>$pickup[city]</option>"; } echo "</select>"."<BR>"; ////////////////// This will end the second drop down list /////////// //// Add your other form fields as needed here///// echo "<input type=submit value=Submit>"; ?> </form> and this is for the next page that organises the form data 'dd-check.php' <?php include 'http://www.gostoke.eu/eu_home.php'; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Demo Multiple drop down list box from plus2net</title> </head> <body> <?php $pickup=$_POST['pickup']; $cat=$_POST['cat']; $subcat=$_POST['subcat']; $load=$_POST['load']; $appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy echo "Date required $appointment_date"."<BR>"; echo "Picking up from $pickup" ."<BR>"; echo "Going to $subcat"."<BR>"; $result = mysql_query("SELECT full_price, half_price, luton FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error()); $row = mysql_fetch_array($result); switch($load) { case 'full_load' : $total = $row['full_price']; break; case 'half_load' : $total = $row['half_price']; break; case 'luton': $total = $row['luton']; break; } $rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC)) { $iPrice = $aRow['price']; echo "£"; echo ($iPrice) + ($total)."<BR>"; } echo "<form method=post name=f2 action='confirm.php'>"; echo 'To confirm the above details, please enter your details below and click submit' . "<br />"; echo 'Full Name' . "<input type='text' name='name' id='name'/>" . "<br />"; echo 'Telephone Number' . "<input type='text' name='telephone' id='telephone'/>" . "<br />"; echo 'Email' . "<input type='text' name='email' id='email'/>" . "<br />"; echo 'Comments:' ."<textarea id='textareainput' name='textareainput' rows='10' cols='22'></textarea>"; echo "<input type='hidden' name='date' id='date' value='$appointment_date'/>"; echo "<input type='hidden' name='pickUpPoint' id='pickUpPoint' value='$pickup'/>"; echo "<input type='hidden' name='destination' id='destination' value='$subcat'/>"; echo "<input type='hidden' name='loadType' id='loadType' value='$load'/>"; echo "<input type='hidden' name='price' id='price' value='($iPrice) + ($total)'/>" . "<br />"; echo "<input type=submit value=Confirm>"; ?> </form> </body> </html> Dont know why its not working properly as said before its fine on my localhost. Hope someone can help. Cheers guys
  7. Hi guys. have amended my option boxes had the following and it worked a treat echo 'Full Load'."<label><input type='radio' name='load' value='full_load'</label>"; echo 'Half Load' . "<label><input type='radio' name='load' value='half_load'</label>"."<BR>"; which calculated the result as follows if ($load == 'full_load') { $total = $row['full_price']; } else { $total = $row['half_price']; } However, I have now added another option box like so echo 'Load from 14m3 - 20m3' . "<label><input type='radio' name='load' value='luton'</label>"."<BR>"; echo 'Load from 7m3 - 14m3'."<label><input type='radio' name='load' value='full_load'</label>"."<BR>"; echo 'Load from 1m3 - 7m3' . "<label><input type='radio' name='load' value='half_load'</label>"."<BR>"; but I am having trouble getting the results calculated with the 3 options have tried the following switch($load) { case "full_load": $total = $row['full_price']; break; case "half_price": $total = $row['half_price']; break; case "luton": $total = $row['luton']; break; } Any help or advice would be most appreciated
  8. Hi guys. Well am nearly there with my first PHP project, its been difficult at time but I have got the results to display the information I want. BUT. What I would like to do is to display the results from my form to be displayed on the same page. Is it possible to do this. this is the code that handles the form. <form method=post name=f1 action='dd-check.php'> <select name = 'day' class="listBox" tabindex="4" > <?php // generate day numbers for ($x = 1; $x <= 31; $x++) { echo "<option value = $x>$x</option>"; } ?> </select> <select name = 'month' class="listBox" tabindex="4" > <?php // generate month names for ($x = 1; $x <= 12; $x++) { echo "<option value=$x>".date('F', mktime(0, 0, 0, $x, 1, 1)).'</option>'; } ?> </select> <select name = 'year' class="listBox" tabindex="4" > <?php // generate year values for ($x = 2007; $x <= 2008; $x++) { echo "<option value=$x>$x</option>"; } ?> </select> <br /> <? /* If register_global is off in your server then after reloading of the page to get the value of cat from query string we have to take special care. To read more on register_global visit. http://www.plus2net.com/php_tutorial/register-globals.php */ @$cat=$_GET['cat']; // Use this line or below line if register_global is off //@$cat=$HTTP_GET_VARS['cat']; // Use this line or above line if register_global is off ///////// Getting the data from Mysql table for Pick Up list box////////// $querPick=mysql_query("SELECT city, id FROM uk_place"); if (!$querPick) { exit('<p>Unable to obtain category list from the ' . 'database.</p>'); } ///////////// End of query for first list box//////////// ///////// Getting the data from Mysql table for first list box////////// $quer2=mysql_query("SELECT DISTINCT country,id FROM eu_place order by country"); ///////////// End of query for first list box//////////// /////// for second drop down list we will check if category is selected else we will display all the subcategory///// if(isset($cat) and strlen($cat) > 0){ $quer=mysql_query("SELECT DISTINCT city FROM eu_place where id=$cat order by city"); }else{$quer=mysql_query("SELECT DISTINCT city FROM eu_place order by city"); } ////////// end of query for second subcategory drop down list box /////////////////////////// /// Add your form processing page address to action in above line. Example action=dd-check.php//// ////////// Starting of first drop downlist ///////// echo "<select name='cat' onchange=\"reload(this.form)\"><option value=''>Select one</option>"; echo mysql_error(); while($noticia2 = mysql_fetch_array($quer2)) { if($noticia2['id']==@$cat){echo "<option selected value='$noticia2[id]'>$noticia2[country]</option>"."<BR>";} else{echo "<option value='$noticia2[id]'>$noticia2[country]</option>";} } echo "</select>"."<BR>"; ////////////////// This will end the first drop down list /////////// ////////// Starting of second drop downlist ///////// echo "<select name='subcat'><option value=''>Select one</option>"; while($noticia = mysql_fetch_array($quer)) { echo "<option value='$noticia[city]'>$noticia[city]</option>"; } echo "</select>"."<BR>"; ////////////////// This will end the second drop down list /////////// echo 'Full Load'."<label><input type='radio' name='load' value='full_load'</label>"; echo 'Half Load' . "<label><input type='radio' name='load' value='half_load'</label>"."<BR>"; ////////// Starting of second drop downlist ///////// echo "<select name='pickup'><option value=''>Select one</option>"; while($pickup = mysql_fetch_array($querPick)) { echo "<option value='$pickup[city]'>$pickup[city]</option>"; } echo "</select>"."<BR>"; ////////////////// This will end the second drop down list /////////// //// Add your other form fields as needed here///// echo "<input type=submit value=Submit>"; ?> </form> and this is the code that displays my results <?php $pickup=$_POST['pickup']; $cat=$_POST['cat']; $subcat=$_POST['subcat']; $load=$_POST['load']; $appointment_date = sprintf('%02d-%02d-%04d',$_POST['day'], $_POST['month'], $_POST['year']); //mm-dd-yyyy echo "Date required $appointment_date"."<BR>"; echo "Picking up from $pickup" ."<BR>"; echo "Going to $subcat"."<BR>"; $result = mysql_query("SELECT full_price, half_price FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error()); $row = mysql_fetch_array($result); if ($load == 'full_load') { $total = $row['full_price']; } else { $total = $row['half_price']; } $rResult = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error()); while ($aRow = mysql_fetch_array($rResult, MYSQL_ASSOC)) { $iPrice = $aRow['price']; echo "£"; echo ($iPrice) + ($total); } ?> know that its go to have something to do with the form action, but don't know where to start, have tried a couple of things but no joy
  9. tried both urs andy and orio and still no joy. Am tearing my hair out...aaarrggghh
  10. Hi. Am having trouble adding together two values that are stored in two sql queries. The values are stored in variables but cannot get it to calulate and display on my webpage. 1. $result = mysql_query("SELECT full_price, half_price FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error()); 2. $row = mysql_fetch_array($result); 3. if ($load == 'full_load') { 4. echo (" "). $row['full_price']; 5. } else { 6. echo (" "). $row['half_price']; 7. } 8. $resultPickup = mysql_query("SELECT price FROM uk_place WHERE city = '" . mysql_real_escape_string($pickup) . "'") or die(mysql_error()); 9. $rowPickup = mysql_fetch_array($resultPickup); And the code I have tried to use to calculate the values is echo $rowPickup['price'] + $row['full_price']; but am getting a blank screen. Any ideas guys
  11. Got it workin now thanks did the following $result = mysql_query("SELECT full_price, half_price FROM eu_place WHERE city = '" . mysql_real_escape_string($subcat) . "'") or die(mysql_error()); $row = mysql_fetch_array($result); if ($load == 'full_load') { echo $row['full_price']; } else { echo $row['half_price']; }
  12. Hi. I have created a database called europe and a table called eu_place with the following fields and data ---------------------------------------------------------------------- id | country | city | full_price | half_price 1 | France | Paris | 50 | 50 2 | Spain | Barcelona | 70 | 85 Now what I am trying to do is to show a user a price based on the country selected from a drop down list, a city selected from a drop down list and then the user chooses full load price or half load price for that city and it displays the price. I have managed to get the user to choose the country and city and I get the user to chooses the full load price or half load price but I think something is not right with my SQL. This is the code that calculates the results, not sure if it is to do with the sql statement if ($load =='full_load'){ $result=mysql_query("SELECT full_price from eu_place where city = '$subcat' "); } else {$result=mysql_query("SELECT half_price from eu_place where city = '$subcat' "); } here is all the code $cat is the country $subcat is the city $load is the radio button full load or half load Hope someone can help cheers guys, its been tearing my hair out <?php include 'dd.php'; ?> <!doctype html public "-//w3c//dtd html 3.2//en"> <html> <head> <title>Demo Multiple drop down list box from plus2net</title> </head> <body> <?php $cat=$_POST['cat']; $subcat=$_POST['subcat']; $load=$_POST['load']; echo "Value of \$cat = $cat <br>Value of \$subcat = $subcat"."<BR>"; echo "Value of \$load = $load"; if ($load =='full_load'){ $result=mysql_query("SELECT full_price from eu_place where city = '$subcat' "); } else {$result=mysql_query("SELECT half_price from eu_place where city = '$subcat' "); } echo mysql_error(); while ($row = mysql_fetch($result)) { echo $row; } ?> </body> </html>
  13. Hi, I have a page http://www.athene-hairandbeauty.co.uk/appointment.html with a number of checkboxes. What I need to do is allow the user to check the boxes and when submit is clicked the data is sent to an email address. How can I achieve this have done it before with textboxes etc., but with the checkboxes no data is passed. Think I need an array in my php, any ideas how I can achieve this. The following is code to what I used when using textboxes, hope someone can point me in the right direction. Cheers guys. <? $option = $_POST["SalonVsPrices_Key"]; $email = $_POST["email"]; $message = $_POST["message"]; $date = date ("j m Y hh:mm", strtotime("now")); $message = $_POST["message"]; $message = <<<EOF Enquiry from $name \r\n Email address: $email\r\n Made on $date\r\n who left the following message: \r\n $message EOF; $to = "enquiries@exploitation.org.uk"; // To email address $subject = "Enquiry from Athene Hair and Beauty Contact Page"; $headers = 'From: $to'. "\r\n" . 'Reply-To: $to' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); if(mail($to, $subject, $message, $headers)) { header("Location: ContactResponse.html"); exit; } else { echo "error in mail"; };";
×
×
  • 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.