Jump to content

VinceGledhill

Members
  • Posts

    133
  • Joined

  • Last visited

Everything posted by VinceGledhill

  1. Hello People. I have a site that I am trying to paste multiple pins on a single map in a wordpress site, using cbxgooglemap plugin and advanced custom fields for my lat and long information. The following code works fine for one pin, on one map. echo do_shortcode('[cbxgooglemap lat="'.get_field('latitude').'" lng="'.get_field('longitude').'" ]'); However, when I try to post it within the loop, I simply get multiple maps, instead of one map, with multiple pins. Here is the code that doesn't work correctly, it gives me 3 maps. <?php $justMap = new WP_Query(array( 'posts_per_page'=> 3, 'post_type' => 'airfield_card' )); while($justMap->have_posts()){ $justMap->the_post(); echo do_shortcode('[cbxgooglemap lat="'.get_field('latitude').'" lng="'.get_field('longitude').'" ]'); } ?> Please can someone tell me how to alter the code so that a single map is outside the loop, but still embedding each pin from the loop. Kind Regards VinceGledhill
  2. No, I'm looking to have a PHP site instead of using joomla. I have been building it in a temp directory http://www.airfieldcards.com/vg_temp/by_name.php I get the menus to show on the left, but don't get it to load the correct card. It simply shows a blank card on the right.
  3. HI People. I have a website which uses Joomla. However, it's a pain in the backside to administer. Everything has to be done three fold in the back end to get anything done. Could someone point me towards somewhere where I can learn how to make the menu dynamically with information from the DB? Regards Vince Gledhill
  4. Thanks for the input. Where do I put that into my code exactly, sorry, I am ancient.
  5. Hi People. This php loads all the airfield names into the correct place. <?php include("db_connect.php"); $users_sql = "SELECT * FROM users ORDER by username"; $users_query = mysql_query($users_sql) or die (mysql_error()); $rsUsers = mysql_fetch_assoc ($users_query); $id = ( !isset ( $id ) ) ? ( int ) $_GET [ "id" ] : $id ; ?> <h2>Airfields By Name</h2> <?php do { ?> <li><a href="<? echo $rs["user_id"]; ?>"><?php echo $rsUsers ['username']; ?> </a></li> <?php } while ($rsUsers = mysql_fetch_assoc ($users_query)); ?> See http://www.airfieldcards.com/vg_temp/by_name.php What do I need to add to the above php to load the actual airfield into results.php in order to show "results.php" in the section of the page where the map is currently shown. (known as "col1" in my css)
  6. The reason was down to php calling other php pages. Those pages having header information in there.... I have now removed it all and it validates, cheers.
  7. Hi People. I have been putting a site together. Here is my CSS code @charset "UTF-8"; /* CSS Document */ <style media="screen" type="text/css"> /* <!-- */ /* General styles */ body { margin:0; padding:0; border:0; /* This removes the border around the viewport in old versions of IE */ width:100%; background:#000000; /* The min-width property does not work in old versions of Internet Explorer */ font-size:90%; text-align:center; } a { color:#369; } a:hover { color:#fff; background:#369; text-decoration:none; } h1, h2, h3 { margin:.8em 0 .2em 0; padding:0; } p { margin:.4em 0 .8em 0; padding:0; } img { /* margin:10px 0 5px; */ } /* Header styles */ #header { clear:both; float:center; width:100%; } #header { border-top:1px #06F; border-bottom:5px double #0000FF /*url(img/border_01.png)*/; background-color:#158ed8; /*test header border-bottom position */ } #header p, #header h1, #header h2 { padding:.4em 15px 0 15px; margin:0; border-bottom:url(img/border_01.png); } #header ul { clear:left; float:left; width:100%; list-style:none; margin:10px 0 5px 0; padding:0; border-top:5px; border-color:FF0000; } #header ul li { display:inline; list-style:none; margin:0; padding:0; } #header ul li a { display:block; float:left; margin:0 0 0 5px; padding:0px 10px; text-align:center; background:#22a0c4; color:#ffffff; text-decoration:none; position:relative; left:15px; line-height:1.3em; } #header ul li a:hover { background:#0000ff; /* bluey green color background of the menu butons */ color:#ffffff; } #header ul li a.active, #header ul li a.active:hover { color:#FFFFFF; background:#0000FF; font-weight:bold; } #header ul li a span { display:block; } /* 'widths' sub menu */ #layoutdims { /*this is the advert section */ clear:both; background:#d5dffb; /*vince light blue background */ border-top:1px solid #0000FF; margin:0; padding:6px 15px !important; text-align:center; } #fixed { margin:0 auto; width:1200px; /* you can use px, em or % */ text-align:left; } /* column container */ .colmask { position:relative; /* This fixes the IE7 overflow hidden bug and stops the layout jumping out of place */ clear:both; float:left; width:1200px; /* width of whole page */ overflow:hidden; /* This chops off any overhanging divs */ } /* holy grail 3 column settings */ .holygrail { background:#d5dffb; /* Right column background colour */ } .holygrail .colmid { float:left; width:200%; margin-left:-12em; /* Width of right column */ position:relative; right:100%; background:#FFFFFF; /* Centre column background colour */ } .holygrail .colleft { float:left; width:100%; margin-left:-50%; position:relative; left:24em; /* Left column width + right column width */ background:#d5dffb; /* Left column background colour */ } .holygrail .col1wrap { float:left; width:50%; position:relative; right:175px; /* Width of left column */ padding-bottom:1em; /* Centre column bottom padding. Leave it out if it's zero */ } .holygrail .col1 { margin:0 208px; /* was 208px Centre column side padding: Left padding = left column width + centre column left padding width Right padding = right column width + centre column right padding width */ position:relative; left:199%; overflow:hidden; } .holygrail .col2 { float:left; float:right; /* This overrides the float:left above */ width:150px; /* Width of left column content (left column width minus left and right padding) */ position:relative; right:5px; /* Width of the left-had side padding on the left column */ } .holygrail .col3 { float:left; float:right; /* This overrides the float:left above */ width:150px; /* Width of right column content (right column width minus left and right padding) */ margin-right:5px; /* Width of right column right-hand padding + left column left and right padding */ position:relative; left:48%; } /* Footer styles */ #footer { clear:both; text-align:center; background-color:#36C; color:#FFFFFF; width:100%; border-top:3px solid #0000FF; border-bottom:3px solid #0000FF; } #footer p { padding:10px; margin:0; } /* --> */ </style> <!--[if lt IE 7]> <style media="screen" type="text/css"> .col1 { width:100%; } </style> <![endif]--> Here is the site which is overflowing, please can you tell me how to fix it? http://www.airfieldcards.com/vg_temp/index.php
  8. PFMaBiSmAd and everyone else, thanks a million for that. I now know that I am far too stupid to learn all this. Your coding I could never have done, it's amazing to me. I was just sick of using the joomla to add a menu item every time, but I'm now getting in so deep, I want to make it happen without taking up too much of you good peoples time. I have the pages set up as follows. CSS running the style (not very good at the moment I know) navmenu.php is the navigation menu that is under the header image sidelinks.php is where I have put your code footer.php is obviously where the footer is. So, the main page (left part) is called "content" in the CSS and the navigation part of the page is called "right-col" in the CSS, and has a php include statement to grab that. How do I get the individual airfield menu to come up under the "alpha" and then when you click on the "airfield name" show results.php with the correct "card" in the "content" section?
  9. Thanks PFMaBiSmAd. Would it be too much trouble to ask you to show me how? I am getting on a bit and I'm struggling.
  10. Thanks for that. What I would really like to do is to replicate how it works via the joomla front end which is here http://www.airfieldcards.com Any ideas how I can click Alpha, then show the records that start with an "A" then Bravo... etc. Just like it is in the joomla front end.
  11. Thanks carugala, that's a good start, now working in alphabetical order at least. ;-)
  12. Thanks for that. I have tried it here... <?php include("db_connect.php"); $users_sql = "SELECT * FROM users"; $users_query = mysql_query($users_sql) or die (mysql_error()); $rsUsers = mysql_fetch_assoc ($users_query); ?> <h2>News</h2> <div class="scroll"> <h3>31st July 2012</h3> <p class="news">New HTML site created which has made the whole job of adding new airfields that much easier. As soon as you submit an airfield it becomes visible. </div> <li><a href="add.php">Add New Airfield</a></li> <h2>Airfields</h2> <li><a href="alpha.php">Alpha</a></li> <?php do { ?> <li><a href=""><?php echo $rsUsers ['username'] LIKE 'A%'; ?> </a></li> <?php } while ($rsUsers = mysql_fetch_assoc ($users_query)); ?> <li><a href="bravo.php">Bravo</a></li> But get nothing. I have also tried it here <?php include("db_connect.php"); $users_sql = "SELECT * FROM users"; $users_query = mysql_query($users_sql) or die (mysql_error()); $rsUsers = mysql_fetch_assoc ($users_query); ?> <h2>News</h2> <div class="scroll"> <h3>31st July 2012</h3> <p class="news">New HTML site created which has made the whole job of adding new airfields that much easier. As soon as you submit an airfield it becomes visible. </div> <li><a href="add.php">Add New Airfield</a></li> <h2>Airfields</h2> <li><a href="alpha.php">Alpha</a></li> <?php do { ?> <li><a href=""><?php echo $rsUsers ['username']; ?> </a></li> <?php } while ($rsUsers = mysql_fetch_assoc ($users_query)LIKE 'A%'); ?> <li><a href="bravo.php">Bravo</a></li> And still get nothing. I cannot put it in the "SELECT * FROM users" at the top because I want the other menu items to show "B" "C" etc.
  13. Hi People. I am building a database driven menu for my site and with help from some kinds souls on here now have it working of a sorts. http://www.airfieldcards.com/vg_temp/index.php However, my list is shown in no particular order, and would like to order it like so. Alpha (all DB items starting with "a" listed alphabetically Bravo (all DB items starting with "b" listed alphabetically Here is my code so far.... <?php include("db_connect.php"); $users_sql = "SELECT * FROM users"; $users_query = mysql_query($users_sql) or die (mysql_error()); $rsUsers = mysql_fetch_assoc ($users_query); ?> <h2>News</h2> <div class="scroll"> <h3>31st July 2012</h3> <p class="news">New HTML site created which has made the whole job of adding new airfields that much easier. As soon as you submit an airfield it becomes visible. </div> <li><a href="add.php">Add New Airfield</a></li> <h2>Airfields</h2> <ul> <li><a href="alpha.php">Alpha</a></li> <ul> <?php do { ?> <li><a href=""><?php echo $rsUsers ['username']; ?> </a></li> <?php } while ($rsUsers = mysql_fetch_assoc ($users_query)); ?> </ul> <li><a href="bravo.php">Bravo</a></li> <li><a href="charle.php">Charlie</a></li> <li><a href="delta.php">Delta</a></li> <li><a href="echo.php">Echo</a></li> <li><a href="foxtrot.php">Foxtrot</a></li> <li><a href="golf.php">Golf</a></li> <li><a href="hotel.php">Hotel</a></li> <li><a href="india.php">India</a></li> <li><a href="juliet.php">Juliet</a></li> <li><a href="kilo.php">Kilo</a></li> <li><a href="lima.php">Lima</a></li> <li><a href="mike.php">Mike</a></li> <li><a href="november.php">November</a></li> <li><a href="oscar.php">Oscar</a></li> <li><a href="papa.php">Papa</a></li> <li><a href="romeo.php">Romeo</a></li> <li><a href="sierra.php">Sierra</a></li> <li><a href="tango.php">Tango</a></li> <li><a href="uniform.php">Uniform</a></li> <li><a href="victor_zulu.php">Victor - Zulu</a></li> </ul> In the code the } while ($rsUsers = mysql_fetch_assoc ($users_query)); lists all the airfields but I would like to list only those starting with "A" in this section. Please can someone educate me?
  14. Hi People. I am running a site which is mainly built around PHP but am using a joomla front end and I'm getting sick of it. This is because every time a new record is added to the DB I have to manually add a link to the menu to make the "airfield card" visible. What I am trying to do is build a DB driven menu. Here is my code for my connection to the DB <?php $host = 'localhost'; $usr = "theusername"; $password = 'thepassword'; $db_name = 'thedbname'; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); ?> Here is my code that is supposed to show me a list of "airfields" from the 'users' DB and dynamically list the 'username' table contents. <?php include("db_connect.php"); $users_sql = "SELECT * FROM users"; $users_query = mysql_fetch_assoc(users_sql) or die (mysql_error()); $rsUsers = mysql_fetch_assoc ($users_query); ?> <h2>News</h2> <div class="scroll"> <h3>31st July 2012</h3> <p class="news">New HTML site created which has made the whole job of adding new airfields that much easier. As soon as you submit an airfield it becomes visible. </div> <li><a href="add.php">Add New Airfield</a></li> <h2>Airfields</h2> <ul> <li><a href="alpha.php">Alpha</a></li> <ul> <?php do { ?> <li><a href=""><?php echo $rsUsers ['username']; ?> </a></li> <?php } while ($rsUsers = mysql_fetch_assoc ($users_query)); ?> </ul> <li><a href="bravo.php">Bravo</a></li> However, all I am getting is a blank area on the site which is in a temporary home here http://www.airfieldcards.com/vg_temp/add.php Please can someone look at my code and tell me where I'm going wrong.
  15. Without realising it I'm getting into deep water. I don't really understand the PHP as you can obviously see. I have a form on my own site and have modified it here for a friend. However, on my form I only have selections and not checkboxes. I just wanted to know what code I needed to put in to make the "selections" from the checkboxes appear in the database. As said above I was trying to help a friend out but it looks beyond me. I'll have to let him know I'm of no use. Thanks for all your input guys.
  16. this is my code to insert $insert_query = "INSERT INTO HelperFormData (surname, firstname, phone1, phone2, location, qualifications, expertise, assistance, languages, e_mail, consent, published, comments, other_info) VALUES ('$surname', '$firstname', '$phone1','$phone2', '$location', '$qualifications', '$expertise', '$assistance', '$languages', '$e_mail', '$consent', '$published', '$comments', '$other_info')"; As far as I can see there is "expertise" there.
  17. Thanks for that mate, I've added it as you can see but it's not putting the info into the DB when I submit the form. <!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>Stranded Flyer</title> </head> <body> <?php $host = 'localhost'; $usr = "user"; $password = 'password'; $db_name = 'stranded'; //connect to database mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $surname = mysql_real_escape_string($_POST['surname']); $firstname = mysql_real_escape_string($_POST['firstname']); $phone1 = mysql_real_escape_string($_POST['phone1']); $phone2 = mysql_real_escape_string($_POST['phone2']); $location = mysql_real_escape_string($_POST['location']); $qualifications = mysql_real_escape_string($_POST['qualifications']); $expertise = mysql_real_escape_string($_POST['expertise']); $assistance = mysql_real_escape_string($_POST['assistance']); $languages = mysql_real_escape_string($_POST['languages']); $e_mail = mysql_real_escape_string($_POST['e_mail']); $consent = mysql_real_escape_string($_POST['consent']); $published = mysql_real_escape_string($_POST['published']); $comments = mysql_real_escape_string($_POST['comments']); $other_info = mysql_real_escape_string($_POST['other_info']); $errorstring = ""; // default value of errorstring function makeSafe($value) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } $value = mysql_real_escape_string($value); return $value; } if(isset($_POST['submit'])) { // Validate all the code inputs // Captcha Validation require_once('recaptchalib.php'); $privatekey = "etcetcetc"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $errorstring = $errorstring. "Invalid CAPTCHA, please try again"; } else { if ($surname =="") $errorstring = $errorstring. "Surname<br>"; if ($phone1 =="") $errorstring = $errorstring. "phone1<br>"; if ($phone2 =="") $errorstring = $errorstring. "phone2<br>"; if ($location =="") $errorstring = $errorstring. "location<br>"; if ($qualifications =="") $errorstring = $errorstring. "qualifications<br>"; if ($assistance =="") $errorstring = $errorstring. "assistance<br>"; if ($languages =="") $errorstring = $errorstring. "languages<br>"; if ($e_mail =="") $errorstring = $errorstring. "e_mail<br>"; if ($consent =="") $errorstring = $errorstring. "consent<br>"; if ($published =="") $errorstring = $errorstring. "published<br>"; if ($comments =="") $errorstring = $errorstring. "comments<br>"; if ($other_info =="") $errorstring = $errorstring. "other info<br>"; // does the errorstring = "nothing"? } // Figure out which error message to show i.e. field validation or CAPTCHA if ($errorstring !="") if (strstr($errorstring,"CAPTCHA")) echo $errorstring; else echo "You have not put anything in the following fields: <br><br> $errorstring"; //echo "If you have nothing to put in the box please type the word \"None\" or \"N\/A\""; //die ("Please try again, ensuring that you fill out all the fields!"); else { //echo "Your data has been saved"; $insert_query = "INSERT INTO HelperFormData (surname, firstname, phone1, phone2, location, qualifications, expertise, assistance, languages, e_mail, consent, published, comments, other_info) VALUES ('$surname', '$firstname', '$phone1','$phone2', '$location', '$qualifications', '$expertise', '$assistance', '$languages', '$e_mail', '$consent', '$published', '$comments', '$other_info')"; $insert_action = mysql_query($insert_query) or die ('Error During Insert :<br>'.mysql_error().'<br><br>Error occured running the following code :<br>'.$insert_query); $id = mysql_insert_id(); echo "Thank you, Your details have been submitted."; //include "resultcard.php"; // Output what the form looks like // End of how the form looks } } if(!isset($_POST['submit']) || (isset($_POST['submit']) && !empty($errorstring))) { ?> <form name = "form1" method ="post" action=""> <table width="700" border="0" cellspacing="5" cellpadding="5" bgcolor = "#dddddd"> <caption> Please complete: This will only take a few moments but please note the format required for Lat and Long otherwise your location will be mis-represented. All fields are required. </caption> <tr> <td width = "50"> </td> <td width = "240"> </td> <td width = "250"> </td> <td width = "160"><b>Example Input</b></td> </tr> <tr> <td> </td> <td>Surname</td> <td><input type='text' name='surname' size = '40' maxlength='30' value = '<?php echo $surname; ?>'></td> <td>Smith</td> </tr> <tr> <td> </td> <td>First Name</td> <td><input type='text' name='firstname' size = '40' maxlength='30' value = '<?php echo $firstname; ?>'></td> <td>Bill</td> </tr> <tr> <td> </td> <td>Phone 1</td> <td><input type='text' name='phone1' size = '40' maxlength='30' value = '<?php echo $phone1; ?>'></td> <td>07777 777777</td> </tr> <tr> <td> </td> <td> </td> <td>The phone on which you are most likely to be reached</td> <td> </td> </tr> <tr> <td> </td> <td>Phone 2</td> <td><input type='text' name='phone2' size = '40' maxlength= '30'value = '<?php echo $phone2; ?>'></td> <td>0118 123 4567</td> </tr> <tr> <td> </td> <td> </td> <td>Alternative number if available, if you don't have one type "none"</td> <td> </td> </tr> <tr> <td> </td> <td>Location</td> <td><input type='text' name='location' size = '40' maxlength='40'value = '<?php echo $location; ?>'></td> <td>52.289071,-1.952004</td> </tr> <tr> <td> </td> <td> </td> <td colspan="2">IMPORTANT: Enter Enter LAT and LONG in DECIMAL DEGREES FORMAT WITH COMMA SEPARATOR (e.g. 51.341551,-1.936684) - it's easy to get this from a Google Map by RIGHT clicking on your location and then clicking on "WHAT'S HERE" - the LAT & LONG will appear in the search line above the map.</td> </tr> <tr> <td> </td> <td>Qualifications</td> <td><input type='text' name='qualifications' size = '40' maxlength='30' value = '<?php echo $qualifications; ?>'></td> <td><p>LAA Inspector<br /> Licenced Engineer<br /> G.A. Pilot<br /> Constructor<br /> Microlight Pilot<br /> Other </p></td> </tr> <tr> <td> </td> <td>Expertise</td> <td> <!-- <input name="Expertise" type="checkbox" value="Airframes" />Airframes<br /> <input name="Expertise" type="checkbox" value="Engines" />Engines<br /> <input name="Expertise" type="checkbox" value="Props" />Props<br /> <input name="Expertise" type="checkbox" value="Electrics" />Electrics<br /> <input name="Expertise" type="checkbox" value="Avionics" />Avionics<br /> <input type='text' name='expertise' size = '40' maxlength='30' value = '<?php echo $expertise; ?>'> --> <?php if (isset($_POST['Expertise'])) foreach ($_POST['Expertise'] as $exp) { // do what you want with each selected experience echo $exp .'<br />'; } ?> <input name="Expertise[]" type="checkbox" value="Airframes" />Airframes<br /> <input name="Expertise[]" type="checkbox" value="Engines" />Engines<br /> <input name="Expertise[]" type="checkbox" value="Props" />Props<br /> <input name="Expertise[]" type="checkbox" value="Electrics" />Electrics<br /> <input name="Expertise[]" type="checkbox" value="Avionics" />Avionics<br /> </td> <td><p>Airframes<br /> Engines<br /> Props<br /> Electrics<br /> Avionics<br /> Other </p></td> </tr> <tr> <td> </td> <td>Assistance Offered</td> <td><input type='text' name='assistance' size = '40' maxlength='50' value = '<?php echo $assistance; ?>' /></td> <td><p>Air transport<br /> Ground transport<br /> Accommodation<br /> Aircraft Parts<br /> Engineering<br /> Other: </p></td> </tr> <tr> <td> </td> <td>Language Skills</td> <td><input type='text' name='languages' size = '40' maxlength='50' value = '<?php echo $languages; ?>' /></td> <td><p>English / Spanish</p></td> </tr> <tr> <td> </td> <td>e_mail</td> <td><input type='text' name='e_mail' size = '40' maxlength='50' value = '<?php echo $e_mail; ?>' /></td> <td><p>example@mail.net</p></td> </tr> <tr> <td> </td> <td>Consent</td> <td> <select name = "consent"> <option value = "Yes" <?php if ($_POST['consent'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value = "No" <?php if ($_POST['consent'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td> </td> <td colspan="2">By selecting YES I accept that the information I have provided will be displayed on an unlisted Google Maps page (Unlisted means: Shared only with other registered members who have been given the map's URL). I also agree not to use the information on this website for purposes other than for which it is intended and I will report any suspected misuse. Whilst Stranded Flyer endeavours to ensure that the information on this website is correct, we do not warrant its completeness or accuracy; nor do we commit to ensuring that the website remains available or that the material on the website is kept up-to-date.</td> </tr> <td><tr> <td> </td> <td>Published</td> <select name = "published"> <option value = "Yes" <?php if ($_POST['published'] == 'Yes') { echo 'selected="selected"'; } ?>>Yes</option> <option value = "No" <?php if ($_POST['published'] == 'No') { echo 'selected="selected"'; } ?>>No</option> </select> </td> <td>Yes</td> </tr> <tr> <td> </td> <td>Comments</td> <td><textarea name= "comments" input type = 'text' rows = "5" cols = "29" /><?php echo $comments; ?></textarea></td> <td>As much info as possible 500 characters max</td> </tr> <tr> <td> </td> <td>Where did you hear about stranded flyer</td> <td><textarea name= "other_info" input="input" type = 'text' rows = "5" cols = "29" /><?php echo $other_info; ?></textarea></td> <td> </td> </tr> <tr> <td> </td> <td><input type='submit' name='submit' value='Submit Your Info' /></td> <td colspan="2"> <? require_once('recaptchalib.php'); $publickey = "6LfVTtESAetcetc"; // you got this from the signup page echo recaptcha_get_html($publickey); ?></td> </tr> </table> </form> </body> </html> <?php } ?>
  18. Thanks mate, that was the problem. Changed the name index to indics instead and it's now working.
  19. Thanks guys but what if I want multiple choices like this? <input name="Expertise" type="checkbox" value="Airframes" />Airframes<br /> <input name="Expertise" type="checkbox" value="Engines" />Engines<br /> <input name="Expertise" type="checkbox" value="Props" />Props<br /> <input name="Expertise" type="checkbox" value="Electrics" />Electrics<br /> <input name="Expertise" type="checkbox" value="Avionics" />Avionics<br />
  20. Thanks I've added that code to mine and I now get this error on each query I do... The page cannot be displayed, due to a database problem. Query: select * from HelperFormData where index = 200 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'index = 200' at line 1 Surname: Any ideas? Here is the code so far. <?php $host = 'localhost'; $usr = "user"; $password = 'password'; $db_name = 'stranded'; function cr($string){ $clean_string = str_replace("rn","<BR>",$string); return $clean_string; } //$id = 11; if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); // code from PFMaBiSmAd here // The following goes right after your database connection/database select code ... $id = isset($_GET['id']) ? intval($_GET['id']) : false; // condition external numerical integer input (if you want a default value to be used, replace the 'false' keyword with that default value) if($id <= 0){ // not a valid id, handle that condition here... echo "The page cannot be displayed, the requested id is invalid."; } else { // valid id (numerical and > 0) $read_query = "select * from HelperFormData where index = $id"; if(!$results = mysql_query($read_query)){ // query failed due to an error, handle that condition here... echo "The page cannot be displayed, due to a database problem.<br />"; echo "Query: $read_query<br />Error: " . mysql_error(); } else { // query executed, test if it matched a row(s) if(!mysql_num_rows($results)){ // no matching row, handle that condition here... echo "The page cannot be displayed, the query did not match any row(s)."; } else { // matched a row, retrieve and use the data here.... $rs = mysql_fetch_array($results); // you are expecting only one row (i.e. no while(){} loop needed.) echo "The requested id does exist, here's the page with the data ..."; } } } // code from the man above $read_query = "select * from HelperFormData where index = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!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>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> Surname: <? echo $rs["surname"]; ?> <table width="500" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="2"> <tr> <td colspan="5">Record number: <? echo $rs["index"]; ?></td> </tr> <tr> <td width="120" bgcolor = #E6F8EB>Surname</td> <td width="120" bgcolor = #E6F8EB>First Name</td> <td width="120" bgcolor = #E6F8EB>phone1</td> <td width="120" bgcolor = #E6F8EB>phone2</td> <td width="120" bgcolor = #E6F8EB>Location</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo $rs["surname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["firstname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone1"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone2"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["location"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Qualifications</td> <td bgcolor = #dbeff8>Expertise</td> <td bgcolor = #dbeff8>Assistance</td> <td bgcolor = #dbeff8>Languages</td> <td bgcolor = #dbeff8>E-Mail</td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["qualifications"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["expertise"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["assistance"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["languages"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["e_mail"]; ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Consent</td> <td bgcolor = #E6F8EB>Published</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo $rs["consent"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_callsign"]; ?></strong></td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td colspan="5"><p>Comments:<br /> <strong><? echo $rs["comments"]; ?></strong></td> </tr> </table> </body> </html> </html>
  21. This <!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>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> Surname: <table width="500" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="2"> <tr> <td colspan="5">Record number: </td> </tr> <tr> <td width="120" bgcolor = #E6F8EB>Surname</td> <td width="120" bgcolor = #E6F8EB>First Name</td> <td width="120" bgcolor = #E6F8EB>phone1</td> <td width="120" bgcolor = #E6F8EB>phone2</td> <td width="120" bgcolor = #E6F8EB>Location</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong></strong></td> <td bgcolor = #E6F8EB><strong></strong></td> <td bgcolor = #E6F8EB><strong></strong></td> <td bgcolor = #E6F8EB><strong></strong></td> <td bgcolor = #E6F8EB><strong></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Qualifications</td> <td bgcolor = #dbeff8>Expertise</td> <td bgcolor = #dbeff8>Assistance</td> <td bgcolor = #dbeff8>Languages</td> <td bgcolor = #dbeff8>E-Mail</td> </tr> <tr> <td bgcolor = #dbeff8><strong></strong></td> <td bgcolor = #dbeff8><strong></strong></td> <td bgcolor = #dbeff8><strong></strong></td> <td bgcolor = #dbeff8><strong></strong></td> <td bgcolor = #dbeff8><strong></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Consent</td> <td bgcolor = #E6F8EB>Published</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #E6F8EB><strong></strong></td> <td bgcolor = #E6F8EB><strong></strong></td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td colspan="5"><p>Comments:<br /> <strong></strong></td> </tr> </table> </body> </html> </html> Regards VinceG
  22. Hi People. Here is a form that is supposed to read from my database. My primary key is called "index" and I have about 300 records in the database. I wanted to be able to view the records but when I load this page the "php" part is empty. I simply get given a blank form. I know it is connecting to the DB OK because I changed one letter in the password and then got a "can't connect to the database error" just to test it out. <?php $host = 'localhost'; $usr = "the_db_user"; $password = 'not_shared_on_forum'; $db_name = 'stranded'; function cr($string){ $clean_string = str_replace("rn","<BR>",$string); return $clean_string; } //$id = 11; if (!isset($id)) $id = $_GET['id']; mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error()); mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error()); $read_query = "select * from HelperFormData where index = '$id'"; $results = mysql_query($read_query); $rs = mysql_fetch_array($results); ?> <!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>Untitled Document</title> <style type="text/css"> <!-- body,td,th { font-size: 12px; } --> </style></head> <body> Surname: <? echo $rs["surname"]; ?> <table width="500" border="1" bordercolor = "#2c2cf6" textcolor = "#2c2cf6"cellspacing="1" cellpadding="2"> <tr> <td colspan="5">Record number: <? echo $rs["index"]; ?></td> </tr> <tr> <td width="120" bgcolor = #E6F8EB>Surname</td> <td width="120" bgcolor = #E6F8EB>First Name</td> <td width="120" bgcolor = #E6F8EB>phone1</td> <td width="120" bgcolor = #E6F8EB>phone2</td> <td width="120" bgcolor = #E6F8EB>Location</td> </tr> <tr> <td bgcolor = #E6F8EB textcolor = #AC1636><strong><? echo $rs["surname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["firstname"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone1"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["phone2"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["location"]; ?></strong></td> </tr> <tr> <td bgcolor = #dbeff8>Qualifications</td> <td bgcolor = #dbeff8>Expertise</td> <td bgcolor = #dbeff8>Assistance</td> <td bgcolor = #dbeff8>Languages</td> <td bgcolor = #dbeff8>E-Mail</td> </tr> <tr> <td bgcolor = #dbeff8><strong><? echo $rs["qualifications"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["expertise"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["assistance"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["languages"]; ?></strong></td> <td bgcolor = #dbeff8><strong><? echo $rs["e_mail"]; ?></strong></td> </tr> <tr> <td bgcolor = #E6F8EB>Consent</td> <td bgcolor = #E6F8EB>Published</td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td bgcolor = #E6F8EB><strong><? echo $rs["consent"]; ?></strong></td> <td bgcolor = #E6F8EB><strong><? echo $rs["radio_callsign"]; ?></strong></td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> <td bgcolor = #E6F8EB> </td> </tr> <tr> <td colspan="5"><p>Comments:<br /> <strong><? echo $rs["comments"]; ?></strong></td> </tr> </table> </body> </html> </html>
×
×
  • 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.