Jump to content

jesse_james

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jesse_james's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I posted this in the PHP Help section, and it got a lot of replies. One user submitted a working solution. See thread - http://www.phpfreaks.com/forums/index.php/topic,258289.0.html
  2. I managed to get the code from AlexWD to work. Thanks to AlexWD for that contribution. SetToLoki - your solution looks interesting. Does it have anything in it that will render an "unavailable" readout? Thanks to everyone for posting. AlexWD was right on target.
  3. Yeah, Dreamweaver has been aggravating me more and more lately. I'm working on CS4 right now, and I swear I find a new bug every day. SetToLoki - I'm not sure if you meant I should post all of my code. I'm not sure you want me to post my entire php file . Anyways, I've posted a hefty portion of the recordset header code below, in addition to code for the entire repeating region. First, the header code: $maxRows_rsRepeat = 12; $pageNum_rsRepeat = 0; if (isset($_GET['pageNum_rsRepeat'])) { $pageNum_rsRepeat = $_GET['pageNum_rsRepeat']; } $startRow_rsRepeat = $pageNum_rsRepeat * $maxRows_rsRepeat; mysql_select_db($database_dsLink, $dsLink); $query_rsRepeat = "SELECT id, city, placename, category, price FROM travel WHERE category = 'Chad hotels' ORDER BY price ASC"; $query_limit_rsRepeat = sprintf("%s LIMIT %d, %d", $query_rsRepeat, $startRow_rsRepeat, $maxRows_rsRepeat); $rsRepeat = mysql_query($query_limit_rsRepeat, $dsLink) or die(mysql_error()); $row_rsRepeat = mysql_fetch_assoc($rsRepeat); if (isset($_GET['totalRows_rsRepeat'])) { $totalRows_rsRepeat = $_GET['totalRows_rsRepeat']; } else { $all_rsRepeat = mysql_query($query_rsRepeat); $totalRows_rsRepeat = mysql_num_rows($all_rsRepeat); } $totalPages_rsRepeat = ceil($totalRows_rsRepeat/$maxRows_rsRepeat)-1; Now here's the repeating region in the body: <?php do { ?> <div class="repspc"> <dt><a href="chad_hotel.php?articleID=<?php echo $row_rsRepeat['id']; ?>"><?php echo $row_rsRepeat['placename']; ?></a></dt> <dd><strong><?php echo $row_rsRepeat['city']; ?>, Chad</strong><br /> Price: $<?php echo $row_rsRepeat['price']; ?> per night</dd> </div> <?php } while ($row_rsRepeat = mysql_fetch_assoc($rsRepeat)); ?> And of course, the only part we're concerned with is the "price"
  4. AlexWD - I tried your code, and......it sort of worked. When I render the page, every hotel shows up with "price unavailable", rather than just the one hotel that has an empty "price" int field. I like the idea though. Any idea what's wrong? My HTML looks like this: Price: $<?php echo $row['price'] = (empty($row['price'])) ? 'price unavailable' : $row['price']; ?> SetToLoki, I tried your code, and the result blew my mind. Really weird - it somehow broke my repeating region; instead of all of the items in the region repeating, now I just get one hotel listing, but with multiple prices (now the price is repeating, but the entire div doesn't repeat). ProjectFear, your advice sounds GREAT. It's just too bad that I don't know enough to use it. I work in Dreamweaver, and although I have a couple years experience of web design, I don't enough enough to take your advice and make a solution out of it. Thanks for the post though.
  5. It looks like I can change the MySQL "price" field type to some kind of int (smallint, etc), and it will order the hotels by price properly. BUT, NO DICE. I don't have price data for all of the hotels, so I want to put "unavailable" in the price field for a few hotels. Also, I would like to put something like "90-110" in the price field for one. But if I use the int field type, it will change any wording ("unavailable" in this case) to a 0. Is there any workaround for this problem? I would like it to order my numbers properly, but I would also like to be able to put "unavailable" for some of the hotels' price field.
  6. It looks like I can change the MySQL "price" field type to some kind of int (smallint, etc), and it will order the hotels by price properly. BUT, NO DICE. I don't have price data for all of the hotels, so I want to put "unavailable" in the price field for a few hotels. Also, I would like to put something like "90-110" in the price field for one. But if I use the int field type, it will change any wording ("unavailable" in this case) to a 0. Is there any workaround for this problem? I would like it to order my numbers properly, but I would also like to be able to put "unavailable" for some of the hotels' price field.
  7. I have a repeating region on a page that lists hotels. It's supposed to list them from cheapest to most expensive. I have a table set up in MySQL that is simply the numerical price (no dollar signs or anything else - just a number). But, to my surprise, I see the hotels aren't being ordered right. The $100 hotel shows up first, a $400 hotel next, then a $41 hotel, then a $90 hotel. OK, it looks like PHP is looking at the first digit of the number and sorting based on that. So does PHP not know how to count properly? How can I teach it? Here's the code in the recordset: $query_rsRepeat = "SELECT id, city, placename, category, price FROM travel WHERE category = 'Chad hotels' ORDER BY price ASC";
  8. I have a repeating region on a page that lists hotels. It's supposed to list them from cheapest to most expensive. I have a table set up in MySQL that is simply the numerical price (no dollar signs or anything else - just a number). But, to my surprise, I see the hotels aren't being ordered right. The $100 hotel shows up first, a $400 hotel next, then a $41 hotel, then a $90 hotel. OK, it looks like PHP is looking at the first digit of the number and sorting based on that. So does PHP not know how to count properly? How can I teach it? Here's the code in the recordset: $query_rsRepeat = "SELECT id, city, placename, category, price FROM travel WHERE category = 'Chad hotels' ORDER BY price ASC";
  9. First of all, I'm a bit disappointed that no one in this forum contributed to the topic over the last few days. But it does seem to be a busy forum. Thankfully, someone over on the Digital Point PHP forum submitted a working solution, the code for which I have pasted below. <? $feed = file_get_contents('http://weather.yahooapis.com/forecastrss?p=CDXX0003&u=f'); preg_match_all('/<img src="(.*)"\/>/', $feed, $image); if ($image !== false) { //Echo image echo $image[0][0]; echo "<p>"; //Echo image URL echo $image[1][0]; } else { echo "Image Not Available!"; } ?> Just in case someone stumbled upon this post later on and needed the answer (as I often do with forums), I thought I would leave it for them.
  10. I'm familiar with putting PHP into an img src="" to grab an image URL from mySQL, but I need to do something a bit different. As you can see on the Yahoo weather RSS page for Chad feed://weather.yahooapis.com/forecastrss?p=CDXX0003&u=f, they have a picture icon for the current weather. I'm using this RSS feed to set up my own weather page on Chad, and I want to use their icon. I tried using XSL transfer in a img src like this: <img src="<?php $mm_xsl = new MM_XSLTransform(); $mm_xsl->setXML("http://weather.yahooapis.com/forecastrss?p=CDXX0003&u=f"); $mm_xsl->setXSL("x/xsl/pic.xsl"); echo $mm_xsl->Transform(); ?>" /> But of course that didn't work. How can I get data from an XML file placed nicely into an img src=""? Is there any way to bypass XSLT and bring data straight from an XML sheet into a PHP file?
×
×
  • 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.