Jump to content

dbdummy

Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dbdummy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hi, I have a form that uses two arrays one get's a list of courses from the database and one creates dates... i have two questions 1. how do i get the $i and $d value off of the arrays to insert in to the database, but still have each know they belong in the same row? 2. how do i change the dates from a multiselect dates ie, Jun 3, Jun 6, and Jun 12 to 'Jun 3, 6, 12' here is the snippet of code from my select page. $numposts is a value selected on an earlier page. for ($i = 0; $i < $numposts; $i++){ echo "<tr> <td><strong>Course</strong></td> <td>"; $query_course = "SELECT * FROM courses ORDER BY course_number"; $course = mysql_query($query_course) or die(mysql_error()); if (!$result) { } echo "<select name='$session_course$i' id='$session_course$i'> <option selected='selected'>Select Course</option>"; while ($row_course = mysql_fetch_assoc($course)) { $cnumber=$row_course['course_number']; $cnumberid=$row_course['course_id']; echo "<option value='$cnumberid$i'>$cnumber</option>"; } echo "</select></td> <td> <select name='session_dates$i' id='session_dates$i' multiple='multiple' size='4'> <option selected='selected'>Select Date(s)</option>"; $date = mktime(0,0,0); for ($d=0; $d<365; $d++) { $d1 = date('M d Y', $date); $d2 = date('M d Y', $date); echo "<option value='$d1$d'>$d2</option>\n"; $date = strtotime('+1 days', $date); } echo "</select></td>"; } below is currently is my insert statement...but currently gets the error message: $dsessioncourse = $_POST["date_session_id"]; $citycourse = $_POST["session_city_id"]; $monthcourse = $_POST["session_month_year_id"]; $activecourse = $_POST["session_ative"]; $loop = count($_POST) / 2; for ($i = 0; $i < $loop; $i++) { if($_POST["session_course$i"]) $product[$i]["session_course"] = $_POST["session_course$i"]; } for ($d = 0; $d < $loop; $d++) { if ($_POST["$d1$d"]) $product[$d]["session_dates"] = $_POST["$d1$d"]; } foreach ($product as $item) { $course = $item["session_course"]; $sessiond = $item["session_dates"]; $query = mysql_query("INSERT INTO `prodates` (`date_session_id`, `session_month_year_id`, `session_dates`, `session_active`, `session_city_id`, `session_course_id`) VALUES ('$dsessioncourse', '$monthcourse', '$session_d', '$activecourse', '$citycourse', '$course')") or die(mysql_error()); }
  2. pulling out my hair on this one. i am trying to query to group by three different groups. the main group is "Month Year" then in month year is "City" then under each city are multiple "Courses" ie September 2007 city 1 course | dates course | dates course | dates city 2 course | dates course | dates October 2007 city 1 course | dates course | dates course | dates city 2 course | dates course | dates my database table schema CREATE TABLE `prodates` ( `date_id` int(2) NOT NULL auto_increment, `date_session_id` smallint(10) NOT NULL, `session_month_year` varchar(15) NOT NULL, `session_dates` varchar(30) NOT NULL, `session_active` varchar(3) NOT NULL default 'yes', `session_city` varchar(25) NOT NULL, `session_course` varchar(6) NOT NULL, PRIMARY KEY (`date_id`) ) ENGINE=innodb; CREATE TABLE `monthyear` ( `my_id` tinyint(4) NOT NULL auto_increment, `month_year` varchar(20) NOT NULL, PRIMARY KEY (`my_id`) ) ENGINE=innodb; CREATE TABLE `courses` ( `course_id` int(5) NOT NULL auto_increment, `course_number` varchar(7) NOT NULL, `course_name` varchar(60) NOT NULL, PRIMARY KEY (`course_id`) ) ENGINE=innodb; CREATE TABLE `cities` ( `city_id` tinyint(2) NOT NULL auto_increment, `city_name` varchar(15) NOT NULL, PRIMARY KEY (`city_id`) ) ENGINE=innodb; My queries <?php $query_prodates = "SELECT * FROM prodates p LEFT JOIN cities ci ON p.session_city = ci.city_name LEFT JOIN courses co ON p.session_course = co.course_number LEFT JOIN monthyear my ON p.session_month_year = my.month_year WHERE p.session_month_year = p.session_month_year AND p.date_session_id = p.date_session_id ORDER BY my.my_id"; $proschedule = mysql_query($query_prodates) or die(mysql_error()); $row_proschedule = mysql_fetch_assoc($proschedule); $totalRows_proschedule = mysql_num_rows($proschedule); ?> <table width="100%" border="0" align="left" cellpadding="4" cellspacing="0" bordercolor="#666666" class="bodytext"> <tr class="bodytextbold"> <td colspan="3" class="header"></td> </tr> <tr bgcolor="#CCCCCC"> <td colspan="2" class="proheaders"><?php echo $row_proschedule['session_month_year']; ?></td> </tr> <tr bgcolor="#CCCCCC"> <td colspan="2" class="proheaders"><?php echo $row_proschedule['session_city']; ?></td> </tr> <?php do { ?> <tr class="protext"> <td><?php echo $row_proschedule['session_course']; ?></td> <td><?php echo $row_proschedule['session_dates']; ?></td> </tr> <?php } while ($row_proschedule = mysql_fetch_assoc($proschedule)); ?> </table>
  3. no, i have text formatted in css. ie <p><span class="finheader">Here is my Headline</span><br> <span class="protext">here is some text. and here is an external <a href="../about/trainers.php">link</a> blah blah blah.</span></p> <p class="protext">oh, and here is another paragraph. with alot of blah blah blah.</p> <ul> <li class="protext"> here is bullet 1 </li> <li class="protext">here is bullet 2 </li> <li class="protext">here is bullet point number 3</li> </ul> <p class="section">and them some more blah blah text. formatted in a different css style. and i have pages of this stuff. </p> I don't want to break the text up, so what can mysql handle with the above formatted text. can i just copy that as is and paste into the mysql field? or do i need some preformatted something around the whole thing? or do I need to change the tags <p class="section"> etc. to some other type of code? thanks
  4. Hi, i have spent the last couple of hours googling this... I have pages that have quite a bit of css formatted text. multiple paragraphs, unordered lists, headlines, etc. I don't want to have to break this up, but cannot fine what I need to get the text into one field in the database...is this possible? thanks
  5. i have a row in a table that contains 3 columns of information to an event. if they want to add another event (row), i somehow want (perhaps a 4th column that has a button, add another event. and then that whole row would repeat itself in the table. <tr> <td>Event</td> <td> <select name="event" id="event"> <option selected="selected">Select Event Type</option> <?php do { echo "<option value=\"".$row_event['eventId']"". if ($row_event['eventId'] == $row_eventName['eventName']){ echo "selected=\"selected\"". ">".$row_event['eventName'];."</option>"; } while ($row_event = mysql_fetch_assoc($event)); ?> </select> </td> <td><select name="event" id="event" multiple size="4"> <option selected="selected">Select Date(s)</option><?php $date = mktime(0,0,0); for ($i=0; $i<90; $i++) { $d1 = date('Y-m-d', $date); $d2 = date('M d Y', $date); echo "<option value='$d1'>$d2</option>\n"; $date = strtotime('+1 days', $date); } ?> </select> </td> </tr>
  6. Hi I am creating an events manager... some of the events require the selection of multiple dates. I was planning on using a select box for the month and year, and a multiple select for the dates, but it doesn't work if the dates for the event is 'Oct 29, 30, Nov 2, 3' which is essentially how i want them displayed. i searched for multiple days, multiple dates and a calendar select script but none of them were very fruitful or sparked an idea of how to do this. Does anyone know if perhaps i am searching for the wrong term? thanks barbara
  7. Hi, I am trying to figure out how to create my tables and am somewhat stuck, database structures totally confuse me. My end result needs to be a schedule of courses offered in various cities. ie City: Austin Course: 101 Course Description: 101 is this Date: June 5, 6 Course: 102 Course Description: 102 is this Date: June 7, 8, 9 Course: 103 Course Description: 103 is this Date: June 10, 11, 12 City: Houston at Someplace Course: 101 Course Description: 101 is this Date: June 7, 12 Course: 112 Course Description: 112 is this Date: June 13, 14, 14 Course: 123 Course Description: 123 is this Date: June 18, 19, 20 So, I created a table named cities (not even sure if I really need a cities table, but the names can be quite long...ie, the city name may contain where the location is, ie, Tucson at River Rd. and Campbell Ave. in cities I have - place (primary key) - city_name - city_location I created a table named courses in courses I have - ckey (primary key) - course_number - course_name - course_description then I need to create a table named schedule this is where I am most confused I need to know the city_name, city_location, course_name, course_description and the dates for that particular course in that particular city. any help is appreciated.
  8. a simpler way might be [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$insertsql = \"INSERT INTO `people` (`name`, `phone`, `email`) VALUES (\'john doe\', \'555.555.5555\', \'john@john.com\'), (\'joe doe\', \'555.555.5551\', \'joe@john.com\'), (\'jane doe\', \'555.555.5552\', \'jane@john.com\'), (\'jill doe\', \'555.555.5553\', \'jill@john.com\')\"; mysql_query($insertsql, $conn); [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]
×
×
  • 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.