Jump to content

PnzrDrgoon

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by PnzrDrgoon

  1. I haven't used Weather Bug, but here's some info on using Google's Weather API: http://blog.programmableweb.com/2010/02/08/googles-secret-weather-api/
  2. I would guess they do two queries. One to get the videos and their dates and one to get the comments associated with their videos. So there would be two tables that look like Table: videos Video_ID Video_File Date_Inserted Table: comments Comment_ID Video_ID Comment Date_inserted Then the code would look something like: $video_sql="SELECT Video_ID, Video_File, Date_Inserted FROM vidoes ORDER BY Date_Inserted DESC"; $video_query=mysql_query($video_sql); while($video_row=mysql_fetch_assoc($video_query)) { $video_id=$video_row['Video_ID']; $video=$video_row['Video']; $video_date=$video_row['Date_Inserted']; echo '<iframe>$video_row</iframe>'; //Get Comments $comment_sql="SELECT Comment FROM comments WHERE Video_ID = $video_id ORDER BY Date_Inserted"; $comment_query=mysql_query($comment_sql); while($comment_row = mysql_fetch_assoc($comment_query)) { echo $comment_row['Comment']; } }
  3. What kind of field are you using in the table? Have you tried lengthening it?
  4. It's a standards thing really. Both work exactly the same. I come from a C background and prefer: if($var <= $my_mom) { } else { } The biggest reason I prefer this way is because I can then easily match up the curly brackets so I know where each clause ends because they're on the same indentation level.
  5. When you insert into the table make sure you have a field for date_inserted set to a timestamp. Then when you fetch the records with your SQL order by date_inserted. Also it may help to have an index on that table by date_inserted.
  6. In addendum to blueflog: Instead of mysql_fetch_row() use mysql_fetch_assoc() to get an associative array. That way if later someone changes the order of the fields fetched it won't affect the rest of the script. So $day = $row[0]; becomes $day = $row['day']; Then to update: $sql="UPDATE `event` SET `day`=$day, `month`=$month, `year`=$year`, `event`='$event', `type`=$type WHERE `id` = $id"; mysql_query($sql); Of course to do this you'll need to retrieve the ID field in the original SELECT query.
  7. I'm starting to wonder if your my Canadian extended insurance carrier.... If so, this will help me by helping you. 1.) Using SELECT * is sloppy and eats up extra bandwidth gathering columns you don't need. Select only the columns that you are actually using. 2.) WHERE username='$_SESSION['username']'") Try storing $_SESSION['username'] in its own variable and the put that variable into the query. I've tried it your way before and kept getting errors. Try this: $username=$_SESSION['username']; $sql="SELECT `col1`,`col2`,`col3` FROM `members` WHERE `username`='$username' "; $query=mysql_query($sql) OR error_logging_function(); //you do have some sort of error logging function right?
  8. Yay! Answer below. $domdoc=new DOMDocument(); $domdoc->formatOutput=TRUE; //print $domdoc->saveXML(); $empty_cart_xml= '<Order xmlns="http://payments.amazon.com/checkout/2009-05-15/"> <Cart> <Items> <Item>1</Item> <Item>2</Item> <Item>3</Item> </Items> </Cart> <OrderCalculationCallbacks> <CalculateTaxRates>true</CalculateTaxRates> <CalculatePromotions>true</CalculatePromotions> <CalculateShippingRates>true</CalculateShippingRates> <OrderCallbackEndpoint> https://my.endpoint.com/receive.php </OrderCallbackEndpoint> <ProcessOrderOnCallbackFailure>true</ProcessOrderOnCallbackFailure> </OrderCalculationCallbacks> </Order>'; //print $empty_cart_xml; $domdoc->loadXML($empty_cart_xml); print $domdoc->saveXML()."<hr/>"; $item=$domdoc->createElement('Item','4'); $domdoc->getElementsByTagName('Items')->item(0)->appendChild($item); print $domdoc->saveXML();
  9. $domdoc=new DOMDocument(); $domdoc->formatOutput=TRUE; $empty_cart_xml= '<Order> <Cart> <Items> <Item>1</Item> <Item>2</Item> <Item>3</Item> </Items> </Cart> </Order>'; $domdoc->loadXML($empty_cart_xml); print $domdoc->saveXML()."<hr/>"; //works up to this point $xpath=new DOMXPath($domdoc); $items=$xpath->query('Order/Cart/Items'); foreach($itemses AS $items) { $items->appendChild($domdoc->createElement('Item','4')); } print $domdoc->saveXML(); All I want to do is to add a new Item to Items. What am I doing wrong?
  10. I'm trying to make an XML shopping cart that looks like: <Cart> <Items> </Items> </Cart> I want to add an Item node to Items so it looks like: <Cart> <Items> <Item> <SKU>1234</SKU> <Price>3.14</Price> </Item> </Items> </Cart> From what I've tried SimpleXML isn't cutting it (although I may have been trying to do it wrong) so I've tried DOMDocument: --SNIP-- protected $cart=""; function __construct() { $empty_cart_xml= "<Cart> <Items> </Items> </Cart>"; $this->cart=new DOMDocument; $this->cart->loadXML($empty_cart_xml); } public function add_item($sku,$merchant_id,$title,$amount,$curreny_code="USD",$quantity=1) { $node=new DOMNode(); $item=$node->createElement("Item"); $node->appendChild($item); $n_sku=$item->createElement("SKU",$sku); $item->appendChild($n_sku); $n_merchant_id=$item->createElement("MerchantID",$merchant_id); $item->appendChild($n_merchant_id); $n_title=$item->createElement("Title",$title); $item->appendChild($n_title); $n_price=$item->createElement("Price"); $item->appendChild($n_price); $n_amount=$n_price->createElement('Amount',$amount); $n_price->appendChild($n_amount); $n_currency_code=$n_price->createElement('CurrencyCode',$curreny_code); $n_price->appendChild($n_currency_code); $n_quantity=$item->createElement("Quantity",$quantity); $item->appendChild($n_quantity); $this->cart->firstChild->firstChild->appendChild($node); echo $this->cart->saveXML(); } --SNIP-- Can someone explain to me why the above doesn't do what I think it should be doing?
  11. Is it possible to do the following? SELECT `a`.`f1`,`a`.`f2`,`b`.`f3`, `s`.`f4` FROM `a` CASE `a`.`f1` WHEN 1 THEN INNER JOIN `b` ON `a`.`fx`=`b`.`fz` ELSE INNER JOIN `c` AS `s` ON `a`.`fx`=`s`.`fz`
×
×
  • 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.