Jump to content

delux247

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by delux247

  1. Hello all, I have two databases one is called categories it stores an ID and name. The other database table contains questions and answers, and a category ID. When I need to do is list all the categories, Then list all the questions and answers to the respective categories using the category id, also in each category I need to put a divider line between the end of one questions and answer and at the beginning of another. Any help with this is greatly appreciated. Thanks in advance!
  2. Hello all, I am trying to create a hierarchical XML document, I have gotten most of it done, but I need some help with a few more things. What the XML needs to look like is this: <types> <group name="Identity + Print"> <type name="Identity System" selected="1" mode="0"> <aspect id="" /> <aspect id="" /> </type> <type name="Stationery System" selected="0" mode="0"> <type name="Production" selected="1" mode="1" > <aspect id="" /> </type> <aspect id="" /> <aspect id="" /> </type> <type name="Print Collateral" selected="0" mode="0"> <type name="Content" selected="0" mode="1"> <aspect id="" /> <aspect id="" /> </type> <type name="Production" selected="1" mode="1"> <aspect id="" /> </type> </type> </group> <group name="Interactive Media"> <type name="Print Collateral" selected="0" mode="0"> <type name="Content" selected="0" mode="1"> <aspect id="" /> <aspect id="" /> </type> <type name="Production" selected="1" mode="1"> <aspect id="" /> </type> </type> </group> <group name="Motion Graphics"> <type name="Print Collateral" selected="0" mode="0"> <type name="Content" selected="0" mode="1"> <aspect id="" /> <aspect id="" /> </type> <type name="Production" selected="1" mode="1"> <aspect id="" /> </type> </type> </group> </types> and here is the PHP: <?php header("Content-Type: application/xml"); echo "<types>"; require_once('php/crud.php'); require_once('php/dBug.php'); ini_set("display_errors","2"); ERROR_REPORTING(E_ALL); $CRUD = new CRUD('types'); $CRUD->addWhere('type_id = 0'); $rows = $CRUD->read(); // get array of items with parent #0 $groups = array(); foreach($rows as $row) { $groups[] = $row; } //new dbug($groups); foreach ($groups as $group) { $SCRUD = new CRUD('types'); $SCRUD->addWhere('type_id = '.$group['id']); $data = $SCRUD->read(); $FCRUD = new CRUD('types'); $FCRUD->addWhere('type_id = '.$data[0]['id']); $fdata = $FCRUD->read(); // get array of items with parent $group[iD] $types = array(); foreach($data as $type) { $types[] = $type; } $types2 = array(); foreach($fdata as $ftype) { $types2[] = $ftype; } $types = array_merge($types, $types2); if (!$types) { // write empty <group /> echo "<group />"; //continue; } // write opening <group> echo "<group name='".$group['name']."'>"; foreach ($types as $type) { $aspects = array(); // get array of items with parent $type[iD] $TCRUD = new CRUD('aspects_types'); $TCRUD->addWhere('type_id = '.$type['id']); $adata = $TCRUD->read(); $aspects = array(); foreach($adata as $aspect) { $aspects[] = $aspect; } //new dbug($aspects); if (!$aspects) { // write empty <type /> //echo "<type />"; // continue; } // write opening <type> $child_group = ($row['name'] == "radio") ? (0) : (1); echo "<type name='".$type['name']."' id='".$type['id']."' selected='".$type['default_selected']."' mode='".$child_group."'>"; foreach ($aspects as $aspect) { echo "<aspect id='".$aspect['aspect_id']."'></aspect>"; } // write closing </type> echo "</type>"; } // write closing </group> echo "</group>"; } // write closing </types> echo "</types>"; ?> I have two tables that I'm working with. The first table is types, it looks like this: id :::::::::::: name ::::::::::::: type_id 1 :::::::::: Identity + print::::: 0 2 :::::::::: Interactive ::::::::: 0 3 :::::::::: Motion ::::::::::::: 0 4 :::::::::: Identity ::::::::::: 1 5 :::::::::: Stationery :::::::: 1 6 :::::::::: Print Coll :::::::::: 1 7 :::::::::: Production :::::::: 5 8 :::::::::: Content ::::::::::: 6 9 :::::::::: Production :::::::: 6 etc... I also have a table called aspects_types that looks like this aspect_id ::::::: type_id 1 :::::::::::::::::4 2 :::::::::::::::::5 2 :::::::::::::::::6 etc... There are 3 records with type_id = 0 these are the groups, in each group there are types, types can have aspects and more types within them. My problem is that I can not get the types that are within higher level types to display. I am at a total loss right now and really need some help. If you need anymore info just ask and I'll get it to you. Thanks in advance!
  3. basically I have multiple forms for multiple clients. I need to be able to add update and delete, the ad and delete are working fine but the update is not. i have narrowed the reason down the my $_POST array. The code below shows how I am doing my update. if(isset($_POST['soq_references'])) { $SCRUD = new CRUD('soq_references'); $SCRUD->setFieldsArray(array('type')); //set fields from database that need to be updated new dbug($_POST['soq_references']); foreach($_POST['soq_references'] as $id=>$reference) { extract($reference); $SCRUD->newWhere("`id` = '$id'"); $SCRUD->update(array($type)); } } when I do a dbug on $_POST['soq_references'] this is what I see, as you can see all of the values have \' before and \' after. I need help getting rid of these slashes and quotes. Thank you in advance for any help regarding this matter. It is greatly appreciated. If you need more info just ask.
  4. @ober, I want to do it with the database and had tried what you suggested before. that doesn't work, I double check and put your code in and it still doesn't work. I get this mysql 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 'news_date >= DATE_ADD(NOW() - 6 MONTHS) ORDER BY news_date DESC' this is my sql stament SELECT news_id, news_title, news_date, publications.publications_title, publications.publications_link FROM news LEFT JOIN publications ON news.news_pdf=publications.publications_id WHERE `news_date` >= DATE_ADD(NOW() - 6 MONTHS) ORDER BY news_date DESC";
  5. This is the code that i tired to configure the date with. I don't know if i did this correctly. <?php $sixmonth = mktime(0,0,0,date("m"),date("d")-180,date("Y")); $month = date("m/d/Y", $sixmonth); $date = $row_news['news_date']; //date in database this code is what will display if($totalRows_news>0 && $month >= $date){ ?> <?php do { ?> <div class="newsitem"> <h3><?php echo date('F j, Y', strtotime($row_news['news_date'])); ?></h3> <a href="index.php?news_id=<?php echo $row_news['news_id']; ?>"><?php echo $row_news['news_title']; ?></a> </div> <?php } while ($row_news = mysql_fetch_assoc($news)); ?> <?php } ?> again im not sure if this is correct, but it is what i came up with...
  6. Yes, I have a field called "news_date" and it has the date in this format "2006-08-14"
  7. Hello all, I Have information that is coming from a database, I would only like to display the records whose date is only 6 months old from the current date. I have tried a few things but had no luck. ??? I am really stuck on this. if you need more information please let me know. Thank you in advance.
×
×
  • 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.