Jump to content

barniegilly

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by barniegilly

  1. I tried that with the following code but this error XML Parsing Error: junk after document element Location: http://localhost/HorseEventsUk/events-feed2.php Line Number 2, Column 1:<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'> ^ <?php require_once("includes/connections.php"); require_once("includes/functions.php"); require_once("backend/includes/twd_functions.php"); function EchoRowItem($row,$item_name,$as_html,$row_item_name=null) { if ($row_item_name) $item_value=htmlentities($row[$row_item_name]); else $item_value=htmlentities($row[$item_name]); return EchoTag($item_name,$item_value,$as_html); } function EchoTag($item_name,$item_value,$as_html) { $s='<'.$item_name.'>'.$item_value.'</'.$item_name.'>'; if ($as_html) echo htmlentities($s).'<br />'; else return $s; } function FindVenueCountyName($venue_id) { $sql="SELECT county_id FROM `venue` WHERE ven_id='$venue_id' LIMIT 1;"; $county_id=FindMySQLResultValue($sql,'county_id'); return ucfirst(FindCountyName($county_id)); } function FindVenueCountyId($venue_id) { $sql="SELECT county_id FROM `venue` WHERE ven_id='$venue_id' LIMIT 1;"; return FindMySQLResultValue($sql,'county_id'); } function FindVenuePostcode($venue_id) { $sql="SELECT post_code FROM `venue` WHERE ven_id='$venue_id' LIMIT 1;"; return FindMySQLResultValue($sql,'post_code'); } function BuildEventURL($event_id,$county_id) { return 'http://horseeventsuk.com/event?url_countyid='.$county_id.'&url_eventid='.$event_id; } $output_as_html=false; if ($output_as_html) echo '<html><head><title>Events Feed</title></head><body><h1>Events Feed</h1>'; $xml='<events>'; $sql="SELECT * FROM `events` WHERE event_status='live' ORDER BY event_created DESC LIMIT 10;"; $result=mysql_query($sql); if ($result) { while ($row=mysql_fetch_array($result)) { $event_id=$row['event_id']; $venue_id=$row['ven_id']; $county_id=FindVenueCountyId($venue_id); //print("Found event ".$event_id.'<br />'); $xml.='<event>'; $xml.=EchoRowItem($row,'eventid',$event_id); $xml.=EchoRowItem($row,'title',$output_as_html); $xml.=EchoRowItem($row,'description',$output_as_html,'event_details'); $xml.=EchoTag('contact_email','gilly@rackfield.co.uk',$output_as_html); $xml.=EchoTag('county',FindVenueCountyName($venue_id),$output_as_html); $xml.=EchoTag('postcode',FindVenuePostcode($venue_id),$output_as_html); $xml.=EchoTag('website_address',BuildEventURL($event_id,$county_id),$output_as_html); $xml.=EchoRowItem($row,'startdate',$output_as_html); $xml.=EchoTag('category','Animals, Convservation',$output_as_html); $xml.=EchoTag('category','Sport',$output_as_html); $xml.=EchoTag('category','Exhibitions, Shows',$output_as_html); $xml.='</event>'; } } $xml.='</events>'; if ($output_as_html) echo '</body></html>'; else { // serve the xml file header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo $xml; } exit; ?>
  2. I am working on a feed but am getting the nesting wrong, the </event> is appearing at the end of the whole feed and not at the end of the particular event. Here is a link to the feed http://www.horseeventsuk.com/events-feed-test.php and my code is ?> <?php :'( $output_as_html=false; if ($output_as_html) echo '<html><head><title>Events Feed</title></head><body><h1>Events Feed</h1>'; $xml='<events>'; $sql="SELECT * FROM `events` WHERE event_status='live' ORDER BY event_created DESC LIMIT 3;"; $xml.='<event>'; $result=mysql_query($sql); if ($result) { while ($row=mysql_fetch_array($result)) { $event_id=$row['event_id']; $venue_id=$row['ven_id']; $county_id=FindVenueCountyId($venue_id); //print("Found event ".$event_id.'<br />'); $xml.=EchoRowItem($row,'title',$output_as_html); //$xml.=EchoRowItem($row,'description',$output_as_html,'event_details'); $xml.=EchoTag('contact_email','gilly@rackfield.co.uk',$output_as_html); $xml.=EchoTag('county',FindVenueCountyName($venue_id),$output_as_html); $xml.=EchoTag('postcode',FindVenuePostcode($venue_id),$output_as_html); $xml.=EchoTag('website_address',BuildEventURL($event_id,$county_id),$output_as_html); $xml.=EchoRowItem($row,'startdate',$output_as_html); $xml.=EchoTag('category','Animals, Convservation',$output_as_html); $xml.=EchoTag('category','Sport',$output_as_html); $xml.=EchoTag('category','Exhibitions, Shows',$output_as_html); } } $xml.='</event>'; $xml.='</events>'; if ($output_as_html) echo '</body></html>'; else { // serve the xml file header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>'; echo $xml; } exit; 18084_.php
  3. hi silly little question but if I want to bracket something inside PHP how do I do it eg my code is <th class="alignright"><?php echo $ass_descrip; ?> (<?php echo $ass_accro ; ?>) <?php echo FindTypeName ($type_id); ?></th> printing out British Eventing (BE) But the brackets at the moment are outside the PHP I want to put a conditional on it and include the brackets inside my conditional statement.?
  4. This is all the PHP <?php // 2. NEW USER REGISTRATION<br /> include_once ("../includes/form_functions.inc.php"); // START FORM PROCESSING FOR A NEW REGISTRATION if (isset($_POST['newvenue'])) { // Form has been submitted. $errors = array(); // perform validations on the form data $required_fields = array('ven_name', 'town', 'ven_website'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); $fields_with_lengths = array('ven_name' => 100, 'street' => 60,'area' => 50, 'town' => 30, 'post_code' => 10, 'ven_website' => 100); $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST)); $ven_name = trim(ucwords(mysql_prep($_POST['ven_name']))); $street = trim(ucwords(mysql_prep($_POST['street']))); $area = trim(ucwords (mysql_prep($_POST['area']))); $town = trim(ucwords (mysql_prep($_POST['town']))); $area = trim(ucwords (mysql_prep($_POST['area']))); $county_id = mysql_prep($_POST['county_id']); $post_code = trim(mysql_prep($_POST['post_code'])); $ven_contact = trim(ucwords(mysql_prep($_POST['ven_contact']))); $ven_email = trim(mysql_prep($_POST['ven_email'])); $ven_website = trim(strtolower(mysql_prep($_POST['ven_website']))); $ven_telno = (mysql_prep($_POST['ven_telno'])); $userid = $_POST['user_id']; if ( empty($errors) ) { $query = "INSERT INTO venue (ven_name, street, area, town, county_id, post_code, ven_contact, ven_email, ven_website, ven_telno, user_id) VALUES ('{$ven_name}', '{$street}', '{$area}', '{$town}', '{$county_id}', '{$post_code}', '{$ven_contact}', '{$ven_email}','{$ven_website}', '{$ven_telno}', '{$userid}' )"; $result = mysql_query($query, $connection); if ($result) { $message = redirect_to("controlpanel.php"); } else { $message = "I am sorry but the venue could not be created."; $message .= "<br />" . mysql_error(); } } else { /* this counts the number of errors and informs the user of how many fields were incorrectly entered*/ if (count($errors) == 1) { $message = "There was 1 error in the form."; } else { $message = "There were " . count($errors) . " errors in the form."; } } } else { // Form has not been submitted. $ven_name = ""; $street = ""; $area = ""; $town = ""; $area = ""; $county_id = ""; $post_code = ""; $ven_contact = ""; $ven_telno = ""; $ven_email = ""; $ven_website = ""; $userid = ""; } ?> This is the form <form id="newvenue" action="newvenue.php" method="post"> <?php if (!empty ($message)) {echo "<p class=\"message\">" . $message . "</p>";}?> <?php if (!empty ($errors)) {display_errors($errors); }?><br /> <table id="neweventdisplay" cellpadding="5" border="0"> <tr> <td></td> <td></td> <td><input type="hidden" name="user_id" value="<?php echo $url_userid ['user_id']; ?>" /></td> </tr> <tr> <td><span class="compuls">*</span></td> <td class="heading">Venue Name</td> <td><input class="input50px" id="ven_name" name="ven_name" type="text" value="<?php echo htmlentities($ven_name); ?>" /></td> </tr> </table> I have checked my CSS and cannot see any code that would be changing anything
  5. Hi I have the following for an input form, I was under the impression that ucwords would format the text into Initial Characters, but this does not do that? What have I done wrong? $ven_name = trim(ucwords(mysql_prep($_POST['ven_name'])));
  6. hi all thank you for your help this is the code that is working for me, thank you for your help <?php $website = $org_website; $link = 'http'; $weblink = strpos ($website,$link); if ($weblink !== FALSE ) { echo "<a href=\"$org_website\" target=\"_blank\"> $org_name </a>"; } else { echo FindOrganiserName($org_id); } ?>
  7. Hi I have a page pulling information from mysql table, it lists names, I have these inside a hyperlink so that where there is a website listed for that record then the user can click on the name and move to their website. Only thing is that what happens if there is not a website for that record. I wanted a script so that if there is a website address listed then it prints the hyperlink but where there is not a website address listed that only the name is printed and it is not a hyperlink. I understand that the strpos can be used for this I have written a script but it is only printing out the name even when there is a website address in the row. What is wrong? PHP Version 5.3.4 Any help very much appreciated <?php $website = $org_website; $link = 'http'; $weblink = strpos ($website,$link); if ($weblink === !false) { echo "<a href=\"$org_website;\"> FindOrganiserName($org_id); \"> FindOrganiserName($org_website); </a>"; } else { echo FindOrganiserName($org_id); } ?>
  8. Hi thanks for that, I think I will need to outsource this as beyond what I can do, just need to know which way to go so thank you for your help.
  9. Hi I have tried the mysql forum but have had no joy with an answer to my problem so wondered if php would be better. I want my users to be able to select from 5 different drop down lists where they can chose any combination from 1 up to all 5, I have attached the front end. These lists are being populated from mysql tables. Code for the drop down lists is as follows <form action="horse-events-devon.php?url_countyid=<?php echo urlencode ($url_countyid ['url_countyid']) ; ?>&go" method="POST"> <table id="searchtable"> <tr> <th>Find By Discipline</th> <th>Find By Venue</th> <th>Find By Championship</th> <th>Find By Organiser</th> <th>Equine Association</th> <th>Submit Your Selections</th> </tr> <tr> <td><select name="dis_id"> <?php $upcomingdis = upcomingdis($url_countyid); $upcoming_dis_bycounty = mysql_fetch_assoc ($upcomingdis); ?> <?php do { ?> <option value="<?php echo $upcoming_dis_bycounty ['dis_id']; ?>" > <?php echo $upcoming_dis_bycounty ['dis_description']; ?></option> <?php } while ($upcoming_dis_bycounty = mysql_fetch_assoc ($upcomingdis)); ?></select></td> <td><select name="ven_id"> <?php $upvenbycounty_set = upcoming_venevents_bycounty($url_countyid); $upcoming_ven_bycounty = mysql_fetch_assoc ($upvenbycounty_set); ?> <?php do { ?> <option value="<?php echo $upcoming_ven_bycounty ['ven_id']; ?>" > <?php echo $upcoming_ven_bycounty ['ven_name']; ?></option> <?php } while ($upcoming_ven_bycounty = mysql_fetch_assoc ($upvenbycounty_set)); ?></select></td> <td><select name="champ_id"> <?php $championship_set = findchampionships(); $champlist = mysql_fetch_assoc ($championship_set); ?> <?php do { ?> <option value="<?php echo $champlist ['champ_id']; ?>" > <?php echo $champlist ['champ_description']; ?></option> <?php } while ($champlist = mysql_fetch_assoc ($championship_set)); ?></select></td> <td> <select name="org_id"> <?php $uporgbycounty_set = upcoming_organevents_bycounty($url_countyid); $upcoming_org_bycounty = mysql_fetch_assoc ($uporgbycounty_set); ?> <?php do { ?> <option value="<?php echo $upcoming_org_bycounty ['org_id']; ?>" ><?php echo $upcoming_org_bycounty ['org_name']; ?></option> <?php } while ($upcoming_org_bycounty = mysql_fetch_assoc ($uporgbycounty_set)); ?></select> </td> <td><select name="ass_id"> <?php $upassbycounty_set = upcoming_assevents_bycounty($url_countyid); $upcoming_assbycounty = mysql_fetch_assoc ($upassbycounty_set); ?> <?php do { ?> <option value="<?php echo $upcoming_assbycounty ['ass_id']; ?>" > <?php echo $upcoming_assbycounty ['ass_description']; ?></option> <?php } while ($upcoming_assbycounty = mysql_fetch_assoc ($upassbycounty_set)); ?></select></td> <td><input name="submit" type="submit" /><input name="countyid" type="hidden" value="<?php echo $url_countyid ['url_countyid']; ?>" /></td> </tr> </table> </form> My search processing is as follows <?php if (isset($_POST['submit'])){ if (isset($_GET['go'])){ $countyid = $_POST['countyid']; $ven_id = $_POST['ven_id']; $dis_id = $_POST['dis_id']; $champ_id = $_POST['champ_id']; $org_id = $_POST['org_id']; $event_id = $row['event_id']; $sql = "SELECT DATE_FORMAT (events.startdate, '%a, %d, %b') AS stdate, events.event_id, events.title, events.ven_id, events.org_id, venue.county_id, venue.ven_id, eventdisciplines.event_id, eventdisciplines.dis_id, county.county_id, discipline.dis_id \n" . "FROM events \n" . "LEFT OUTER JOIN eventdisciplines \n" . "ON events.event_id = eventdisciplines.event_id \n" . "LEFT OUTER JOIN discipline \n" . "ON eventdisciplines.dis_id = discipline.dis_id \n" . "LEFT OUTER JOIN venue \n" . "ON events.ven_id = venue.ven_id \n" . "LEFT OUTER JOIN county \n" . "ON venue.county_id = county.county_id \n" . "WHERE events.ven_id = ({$ven_id} OR events.org_id = {$org_id})\n" . "AND events.startdate > NOW()\n" . "AND venue.county_id = {$countyid} \n" . "ORDER BY startdate ASC"; $result = mysql_query ($sql, $connection); ?> How am I best to do this please? my OR within the mysql does not work, should I not be doing this with php in the search processing? someones help would really be appreciated, just to point me in the right direction. [attachment deleted by admin]
  10. This is the front end to my selection form, should I be using php instead of the mysql side? [attachment deleted by admin]
  11. I have worked on it a little more this is now my mysql query $sql = "SELECT DATE_FORMAT (events.startdate, '%a, %d, %b') AS stdate, events.event_id, events.title, events.ven_id, events.org_id, venue.county_id, venue.ven_id, eventdisciplines.event_id, eventdisciplines.dis_id, county.county_id, discipline.dis_id \n" . "FROM events \n" . "LEFT OUTER JOIN eventdisciplines \n" . "ON events.event_id = eventdisciplines.event_id \n" . "LEFT OUTER JOIN discipline \n" . "ON eventdisciplines.dis_id = discipline.dis_id \n" . "LEFT OUTER JOIN venue \n" . "ON events.ven_id = venue.ven_id \n" . "LEFT OUTER JOIN county \n" . "ON venue.county_id = county.county_id \n" [i] . "WHERE (events.ven_id = {$ven_id} AND events.org_id = {$org_id}) \n"[/i] . "AND events.startdate > NOW()\n" . "AND venue.county_id = {$countyid} \n" . "ORDER BY startdate ASC"; I want the user's form as shown on my screen print to be able to either have one or more choices entered, I am unsure of the correct mysql and believe the line that I need to change is as indicated. My code works with both variables entered but My query needs to be and 'AND' 'OR'.
  12. Hi am working on this script and need a little help with the MYSQL bit, The front end is a table with 4 choices where the user can choose either one choice or a combination of choices. I have it working where if they just choose the venue it returns the correct answer however am not coding the rest of the mysql correctly when multipule choices are entered. The database structure consists of multiple tables. My Mysql query is this so far $sql = "SELECT * \n" . "FROM events \n" . "LEFT OUTER JOIN eventdisciplines \n" . "ON events.event_id = eventdisciplines.event_id \n" . "LEFT OUTER JOIN discipline \n" . "ON eventdisciplines.dis_id = discipline.dis_id \n" . "LEFT OUTER JOIN venue \n" . "ON events.ven_id = venue.ven_id \n" . "LEFT OUTER JOIN county \n" . "ON venue.county_id = county.county_id \n" . "WHERE events.startdate > NOW()\n" . "AND events.ven_id = {$ven_id} \n"; The key search criteria is on the county_id and events >NOW from there on it needs to be so that if either of the selections of are made that it returns the records. The logic is that if events.county_id = 2 and events.startdate is greater then today with events.ven_id = 2 and / or events.dis_id = 3 then return the rows. Just missing that and or bit of the mysql I think, unless there is another way I should be doing it. PS JUST READ THE RULES!! MySQL client version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $ [attachment deleted by admin]
  13. Having a thick moment!! what is wrong with my if condition statement. I am looking to have a list of regions and then where the counties id = the regions id the counties show under the counties. Both counties and regions are in a mysql table. This is my php <?php $regions_set = findregion(); while ($regions = mysql_fetch_array ($regions_set)){ echo "<ul>"; echo "<li><a href=\"viewevents.php?url_regionid=" .urlencode ($regions ['region_id']) . "\">" . $regions ['region_description'] . "</a></li>"; $regioncounties_set = findregionscounties(); while ($regioncounties = mysql_fetch_array ($regioncounties_set)){ echo "<ul>"; if ($regioncounties ['county_region'] == 1); echo "<li>" . $regioncounties ['county_description'] . "</li>"; echo "</ul>"; } } ?> table `county` -- INSERT INTO `county` (`county_id`, `county_description`, `county_region`) VALUES (1, 'Cornwall', 1), (2, 'Devon', 1), (3, 'Somerset', 1), (4, 'Wiltshire', 18), region` ( `region_id` int( NOT NULL AUTO_INCREMENT, `region_description` varchar(40) NOT NULL, PRIMARY KEY (`region_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=19 ; -- -- Dumping data for table `region` -- INSERT INTO `region` (`region_id`, `region_description`) VALUES (1, 'South West'), (2, 'South East'), (4, 'Dorset'), (7, 'East Anglia'), (8, 'Home Counties'), (9, 'London & South East'), I have the id of 1 in at the moment but still am not getting the right output
  14. The code I already have is as follows <div id="eventlistings"> <ul> <?php $county_dates_set = get_upcomingdatesincounty ($url_countyid); while ($upcomingcountydates = mysql_fetch_array ($county_dates_set)) { ?> <li> <h2><?php echo $upcomingcountydates ['stdate']; ?></h2> </li> <?php $county_events_set = get_eventsforcounty ($url_countyid); while ($countyevents = mysql_fetch_array ($county_events_set)) { if ($countyevents ['stdate'] == $upcomingcountydates ['stdate']) { ?> <div id="event"> <table> <tr> <td id="title"><h1><?php echo $countyevents ['title']; ?> at <?php echo $countyevents ['ven_name']; ?></h1></td> <td><?php echo $upcomingcountydates ['type_description']; ?></td> </tr> <tr> <td><?php echo $countyevents ['org_name']; ?></td> </tr> <tr> <td><ul> <?php $event_dis_set = event_disciplines (); while ($eventdisiplines = mysql_fetch_array ($event_dis_set)){ if ($eventdisiplines ['event_id'] == $countyevents ['event_id']) { ?> <li><img src="images/pink/box.png" width="8" height="8" /> <?php echo $eventdisiplines ['dis_description'];?></li> </ul> <?php } } ?></td> </tr> <tr> <td><?php echo $countyevents ['ass_acronym']; ?> <?php echo $countyevents ['level_description']; ?> For <?php echo $countyevents ['champ_description']; ?></td> <td class="status"><?php echo $countyevents ['status_description']; ?> </td> </tr> </table> </div> <?php } ?> <?php } ?> <?php } ?> </ul> </ul> </div> And that returns the attached screen shot [attachment deleted by admin]
  15. Hi I am trying to work out the best way to display my events. I want to display them like this January 2011 Sat 1st Event Title Sun 2nd Event Title February 2011 Mon 3rd Event Title What would be the best way of doing this with a foreach loop or if statement?
  16. Seem to be working it out!! I have moved changed the $event_id variable to after the if and it seems to work? <?php $query = "INSERT INTO events (title, event_details, type_id, champ_id, org_id, ven_id, user_id, startdate, level_id, status_id) \n" . "VALUES ('{$title}', '{$event_details}', '{$type_id}', '{$champ_id}', '{$org_id}','{$venue_id}', '{$url_userid}', '{$startdate}', '{$level_id}', '{$status_id}');"; if ($result = mysql_query($query, $connection)) { $event_id = mysql_insert_id(); // Insert Diseases foreach ($_POST['discipline'] AS $key => $value) { mysql_query("INSERT INTO eventdisciplines SET event_id = '" . (int)$event_id . "', dis_id = '" . (int)$key . "'"); } ?> Now just got to work out how I do an update if anyone has some advice it would be greatly appreciated.
  17. Just one other thing, there are two tables being updated in this code and the insert for the events table works fine it is just the insert into the eventdisciplines table that is not quite right, the dis_id is inserted and obviously the evdis_id is created but the event_id is not being passed into the database. I image that as the event_id is being created by the first insert that I am not capturing the event_id to then pass into the next insert?
  18. Hi I have tried to adapt code from another topic on this subject and have got this far. (I have omited parts that should not be relevant to enable you to focus on the relevant code) My checkbox data is coming from a table called discipline and then the selected check box is stored in eventsdisciplines with a foreign key to the events table. Each selected checkbox will have its own row in the eventdiscipline table. ( I understand this would be the best way of handling the query. table `discipline` ( `dis_id` int( NOT NULL AUTO_INCREMENT, `dis_description` varchar(20) NOT NULL, table `eventdisciplines`( `evdis_id` int( NOT NULL AUTO_INCREMENT, `dis_id` int( NOT NULL, `event_id` int( NOT NULL, table `events` ( `event_id` int( NOT NULL AUTO_INCREMENT, `event_title` varchar(20) NOT NULL, `dis_id` int( DEFAULT '999999', My page displays fine with my list of disciplines, however I have not coded the insert query correctly and could do with a little help. My page reads as follows <?php if (intval($_GET['url_userid']) == 0) { redirect_to('controlpanel.php'); } include_once("includes/form_functions.inc.php"); // make sure the subject id sent is an integer // START FORM PROCESSING // only execute the form processing if the form has been submitted if (isset($_POST['submit'])) { // initialize an array to hold our errors $errors = array(); // perform validations on the form data $required_fields = array('title', 'status_id',); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); $fields_with_lengths = array('title' =>36, 'dis_id' <= 6, 'type_id' <= 6, 'champ_id' <= 6, 'dis_id' <= 6, 'org_id' <= 6, 'venue_id' <= 6, 'status_id' <= 6); $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST)); // clean up the form data before putting it in the database $url_userid = mysql_prep($_GET['url_userid']); $title = trim(ucwords(mysql_prep($_POST['title']))); $event_details = mysql_prep($_POST['event_details']); $type_id = mysql_prep($_POST['type_id']); $champ_id = mysql_prep($_POST['champ_id']); $dis_id = mysql_prep($_POST['dis_id']); $org_id = mysql_prep($_POST['org_id']); $venue_id = mysql_prep($_POST['ven_id']); $level_id = mysql_prep($_POST['level_id']); $status_id = mysql_prep($_POST['status_id']); ?> IN THE NEXT BIT OF CODE IS WHERE IT THINK I AM WRONG AND THINK IT IS MY BRACKETING? <?php // Database submission only proceeds if there were NO errors. if (empty($errors)) { $query = "INSERT INTO events (title, event_details, type_id, champ_id, dis_id, org_id, ven_id, user_id, startdate, level_id, status_id) \n" . "VALUES ('{$title}', '{$event_details}', '{$type_id}', '{$champ_id}', '{$dis_id}', '{$org_id}','{$venue_id}', '{$url_userid}', '{$startdate}', '{$level_id}', '{$status_id}');"; $user_id = mysql_insert_id(); // Insert Disciplines foreach ($_POST['discipline'] AS $key => $value) { mysql_query("INSERT INTO eventdisciplines SET event_id = '" . (int)$event_id . "', dis_id = '" . (int)$key . "'"); } if ($result = mysql_query($query, $connection)) { // as is, $message will still be discarded on the redirect $message = "The page was successfully created."; } else { $message = "The page could not be created."; $message .= "<br />" . mysql_error(); } } else { if (count($errors) == 1) { $message = "There was 1 error in the form."; } else { $message = "There were " . count($errors) . " errors in the form."; } } } else { // Form has not been submitted. $url_userid = ""; $title = ""; $event_details = ""; $type_id = ""; $champ_id = ""; $dis_id = ""; $org_id = ""; $venue_id = ""; $level_id = ""; $status_id = ""; } $url_userid = mysql_prep($_GET['url_userid']); ?> </head> This is within the body and a table along with other fields which I have omitted as they are not relevant to this question. <tr> <td><span class="compuls">*</span></td> <td class="heading">Discipline</td> <td><?php // Select All Records from Database $query = mysql_query("SELECT * FROM discipline ORDER BY dis_description ASC") or die('Error: Unable to execute query: ' . mysql_error()); if ($query) { if (is_resource($query)) { $i = 0; $data = array(); while ($result = mysql_fetch_assoc($query)) { $data[$i] = $result; $i++; } mysql_free_result($query); $results = array(); $results = $data; unset($data); } } else { echo '<div class="warning">No results returned</div>'; } $rowOne = 'rowOne'; $rowTwo = 'rowTwo'; $rowCount = 0; ?> <?php foreach ($results as $discipline) { ?> <?php $rowClass = ($rowCount % 2) ? $rowTwo : $rowOne; ?> <div class="<?php echo $rowClass; ?>"><input name="discipline[<?php echo $discipline['dis_id']; ?>]" type="checkbox" /><?php echo $discipline['dis_description']; ?></div> <?php $rowCount++; ?> <?php } ?> </td> </tr>
  19. Hi sorry but still not working, I think the issue is with what it is comparing. The value $url_show ['stand_id'] is the individual value stored in the table. The drop down list value is also coming from the database and if the form has not been submitted it will not be showing a $_POST. So I need it to be comparing against the ID coming from the list containing the drop down items, this is being pulled from the database with $stand_set = getall_stands(); while ($stands = mysql_fetch_array($stand_set)) so the argument would be $stands ['stand_id'] being compared with $url_show ['stand_id'] and then selecting the $stands ['stand_id']
  20. Hi Thank you for that, I have amended the code but the drop down lists still defaults to the first item on the list coming from the database. The attached image shows that whilst the $stand_id is 7 the drop down list has nothing selected and shows the first item in the drop down list where it should be A07 selected. [attachment deleted by admin]
  21. hi I am working on a form which has a drop down list being populated by a mysql database. Aim is to have the item held in the database to be selected on the dropdown list. I have the following code but <select name="stand_id"> <?php $stand_set = getall_stands(); while ($stands = mysql_fetch_array ($stand_set) ) { ?> <option value=" <?php echo $stands ['stand_id']; ?>" <?php if (isset($_POST['stand_id']) == $url_show ['stand_id']) echo 'selected=\"selected\"'; ?> > <?php echo $stands ['stand_descrip']; ?></option> <?php } ?> </select> Whilst this updates the database the drop down list defaults to the first list item instead of the item in the database, any help would be very much appreciated.
  22. Hi I have an update page with multipule drop down menus, I am looking for a way to allow only the drop down menus that have been altered to be sent to the database. One way was to add the following code, where the $type_id equals 0 then add nothing to the database. if ($type_id == 0) { $type_id = ""; } However I am getting a syntex error with this, if I enter a value into the $type_id it selects that fine. eg. if ($type_id == 0) { $type_id = "2"; } What is the right way to send nothing to the database? Fuller code of the page is here <?php require_once("includes/sessions.php"); ?> <?php require_once("includes/connections.php"); ?> <?php require_once("includes/functions.php"); ?> <?php confirm_logged_in();?> <?php usersid(); ?> <?php find_selected_event(); find_selected_region(); ?> <?php $selected_event = getevent_byid ($url_eventid); $orgdescrip = orgdescription($url_eventid); $leveldescrip = leveldescription($url_eventid); $typedescrip = typedescription($url_eventid); $champdescrip = champdescription($url_eventid); $disdescrip = disdescription($url_eventid); $venuedescrip = venuedescription($url_eventid); $statusdescrip = statusdescription($url_eventid); ?> <?php if (!isset($new_event)) {$new_event = false;} ?> <?php // make sure the subject id sent is an integer if (intval($_GET['url_eventid']) == 0) { redirect_to('controlpanel.php'); } include_once("includes/form_functions.inc.php"); // START FORM PROCESSING // only execute the form processing if the form has been submitted if (isset($_POST['submit'])) { // initialize an array to hold our errors $errors = array(); // perform validations on the form data $required_fields = array('title'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); $required_numberfields = array(); $errors = array_merge($errors, check_number_fields($required_numberfields, $_POST)); $fields_with_lengths = array(); $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST)); // clean up the form data before putting it in the database $url_eventid = mysql_prep($_GET['url_eventid']); $user_id = mysql_prep($_POST['user_id']); $title = trim(mysql_prep($_POST['title'])); $event_details = mysql_prep($_POST['event_details']); $type_id = mysql_prep($_POST['type_id']); $champ_id = mysql_prep($_POST['champ_id']); $dis_id = mysql_prep($_POST['dis_id']); $org_id = mysql_prep($_POST['org_id']); $venue_id = mysql_prep($_POST['ven_id']); $level_id = mysql_prep($_POST['level_id']); $status_id = mysql_prep($_POST['status_id']); if ($type_id == 0) { $type_id = ""; } // Database submission only proceeds if there were NO errors. if (empty($errors)) { $sql = "UPDATE events SET \n" . "title = '{$title}',\n" . "event_details = '{$event_details}',\n" . "type_id = {$type_id},\n" . "champ_id = {$champ_id},\n" . "dis_id = {$dis_id},\n" . "org_id = {$org_id},\n" . "ven_id = {$venue_id},\n" . "user_id = {$url_userid},\n" . "level_id = {$level_id},\n" . "status_id = {$status_id}\n" . "WHERE event_id = {$url_eventid} \n" . "LIMIT 1"; if ($result = mysql_query($sql, $connection)) { // as is, $message will still be discarded on the redirect $message = "The event was successfully updated."; // get the last id inserted over the current db connection $new_event_id = mysql_insert_id(); redirect_to("newevent.php"); } else { $message = "I am sorry but the event could not be updated."; $message .= "<br />" . mysql_error(); } } else { if (count($errors) == 1) { $message = "There was 1 error in the form."; } else { $message = "There were " . count($errors) . " errors in the form."; } } // END FORM PROCESSING } ?> <?php /*THIS CODE WITH RETURN IN THE BROWSER THE URLS THAT ARE BEING PULLED DOWN*/ if(empty($_GET)) echo "No GET variables"; else print_r($_GET); ?> <?php include("includes/header.inc.php"); ?> <title>Horse Events</title> <?php include_once("includes/meta.inc.php");?> <?php include_once("includes/cssfavgoogle.inc.php");?> <link href="css/adminpanel.css" rel="stylesheet" type="text/css" /> <style> input[type=number] { width:40px; } </style> </head> <body> <div id="wrapper"> <div id="header"> <img src="images/horseevents_wheretogo.png" align="right" /> <?php require_once ("includes/adminmenu.inc.php"); ?> </div> <div id="adminleft"> <h2>YOUR UPCOMING EVENTS <?php echo "<a href=\"newevent.php?url_userid={$url_userid}\"><img src=\"images/pink/add_event.png\" align=\"right\" width=\"131\" height=\"19\" /></a>" ?></h2> <table id="datetable" width="300" border="0" > <?php $event_users_set = get_upcomingeventsforuser ($url_userid); while ($eventid = mysql_fetch_array ($event_users_set)){ echo"<tr class=\'date\'>"; echo"<td>" . $eventid["stdate"] ."</td>"; echo"<td><a href=\"editevent.php?url_userid={$url_userid}&url_eventid=". urlencode ($eventid['event_id']) . "\">". $eventid ['title'] . "</td>"; echo"</tr></a>"; } ?> </table> <br /> <h2>YOUR PAST EVENTS</h2> <table id="datetable" width="300" border="0" > <?php $event_users_set = get_pasteventsforuser ($url_userid); while ($eventid = mysql_fetch_array ($event_users_set)){ echo"<tr class=\'date\'>"; echo"<td>" . $eventid["stdate"] ."</td>"; echo"<td><a href=\"editevent.php?url_userid={$url_userid}&url_eventid=". urlencode ($eventid['event_id']) . "\">". $eventid ['title'] . "</td>"; echo"</tr></a>"; } ?> </table> </div> <div id="admincontent"> <span class="h1pln">Edit Your Event</span><a class="delete" href="deleteevent.php?url_eventid=<?php echo $url_eventid; ?>" onClick="return confirm('Are you sure you want to delete?')">Delete</a><br /> <span class="h3pln">Please make sure you complete all the compulary fields<span class="compuls">*</span>.<br /> The more accurately you enter your event the more people will be able to then find it. <br /> <br /> If there are any selections we do not currently have available please click here and I will add them to your drop down menus.</span> <?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?> <?php if (!empty($errors)) { display_errors($errors); } ?> <form id="newevent" action="editevent.php?url_eventid=<?php echo urlencode ($selected_event ['event_id']); ?>" method="post"> <table id="neweventdisplay" cellpadding="5" width="400" border="0"> <tr> <td><input type="text" name="event_id" value="<?php echo $url_eventid; ?>" /></td> <td><input type="text" name="user_id" value="<?php echo $url_userid; ?>" /></td> </tr> <tr> <td class="heading">Event Title</td> <td><input id="titleinput" name="title" type="text" value="<?php echo $selected_event ['title']; ?>" /><span class="compuls">*</span><span class="smalltext">Enter up to 36 characters</span></td> </tr> <tr> <td class="heading">Current Status</td> <td><?php echo $statusdescrip ['status_description']; ?> <select name="status_id" > <?php $status_set = findstatus(); $statuslist = mysql_fetch_assoc ($status_set); ?> <?php do { ?> <option value="<?php echo $statuslist ['status_id']; ?>" ><?php echo $statuslist ['status_description']; ?></option> <?php } while ($statuslist = mysql_fetch_assoc ($status_set)); ?></select> <span class="compuls">*</span></td> </tr> <tr> <td class="heading">Organiser</td> <td><?php echo $orgdescrip ['org_name']; ?> <select name="org_id"> <?php $organisers_set = findorganisers(); $orglist = mysql_fetch_assoc ($organisers_set); ?> <?php do { ?> <option value="<?php echo $orglist ['org_id']; ?>" ><?php echo $orglist ['org_name']; ?></option> <?php } while ($orglist = mysql_fetch_assoc ($organisers_set)); ?></select></td> </tr> <tr> <td class="heading">Start Date</td> <td id="dateinput"><?php echo $selected_event ['stdate']; ?></td> </tr> <tr> <td class="heading">Type Of Event</td> <td><?php echo $typedescrip ['type_description']; ?> <select name="type_id"> <?php $type_set = findtype(); $typelist = mysql_fetch_assoc ($type_set); ?> <?php do { ?> <option value="<?php echo $typelist ['type_id']; ?>" ><?php echo $typelist ['type_description'], $typelist ['type_id']; ?></option> <?php } while ($typelist = mysql_fetch_assoc ($type_set)); ?></select><span class="compuls">*</span></td> </tr> <tr> <td class="heading">Venue</td> <td><?php echo $venuedescrip ['ven_name']; ?><select name="ven_id"> <?php $venues_set = findvenues(); $venuelist = mysql_fetch_assoc ($venues_set); ?> <?php do { ?> <option value="<?php echo $venuelist ['ven_id']; ?>" ><?php echo $venuelist ['ven_name'], $venuelist ['ven_id']; ?></option> <?php } while ($venuelist = mysql_fetch_assoc ($venues_set)); ?></select></td> </tr> <tr> <td class="heading">Discipline</td> <td><?php echo $disdescrip ['dis_description']; ?><select name="dis_id"> <?php $discipline_set = finddisciplines(); $dislist = mysql_fetch_assoc ($discipline_set); ?> <?php do { ?> <option value="<?php echo $dislist ['dis_id']; ?>" ><?php echo $dislist ['dis_description'], $dislist ['dis_id']; ?></option> <?php } while ($dislist = mysql_fetch_assoc ($discipline_set)); ?></select><span class="compuls">*</span></td> </tr> <tr> <td class="heading">Level</td> <td><?php echo $leveldescrip ['level_description']; ?> <select name="level_id"> <?php $level_set = findlevels(); $levellist = mysql_fetch_assoc ($level_set); ?> <?php do { ?> <option value="<?php echo $levellist ['level_id']; ?>" ><?php echo $levellist ['level_description'], $levellist ['level_id']; ?></option> <?php } while ($levellist = mysql_fetch_assoc ($level_set)); ?></select></td> </tr> <tr> <td class="heading">Is This A Championship</td> <td><?php echo $champdescrip ['champ_description']; ?><select name="champ_id"> <?php $championship_set = findchampionships(); $champlist = mysql_fetch_assoc ($championship_set); ?> <?php do { ?> <option value="<?php echo $champlist ['champ_id']; ?>" ><?php echo $champlist ['champ_description'], $champlist ['champ_id']; ?></option> <?php } while ($champlist = mysql_fetch_assoc ($championship_set)); ?></select></td> </tr> <tr> <td class="heading">Event Details</td> <td><textarea name="event_details" cols="45" rows="15" ><?php echo $selected_event ['event_details']; ?> </textarea></td> </tr> <tr> <td class="heading">Upload Schedule</td> <td></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" id="convert" value="Update Your Event"></td> </tr> </table> <a class="delete" href="controlpanel.php">Cancel</a> </form> </div> <div id="adminright"> </div> <br clear="all" /> <?php require("includes/lowerlistings.inc.php"); ?> <?php require("includes/footer.inc.php"); ?> </div><!--End of Wrapper--> </body> </html>
  23. I have been working on this and I have set a blank selection in my drop down lists o zero, therefore if I can omit any fields with zero I will not update the drop down lists that have not been selected this time. Therefore if I have a function in my form processing to omit zeros Is this an option, I hope I am thinking along the right lines?
×
×
  • 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.