Re: eof bof in php

From: Date: Sun, 21 Dec 2008 18:45:50 +0000
Subject: Re: eof bof in php
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.general 
Request: Send a blank email to php-general+get-284931@lists.php.net to get a copy of this message
thanks for the advice re html and php mashup!! I will research to find the way to do it outside the php. - Gary Maddock-Greene ""Anthony Gentile"" <asgentile@gmail.com> wrote in message news:2ce4207d0812211021g215d5346wb0afcedf039ef22d@mail.gmail.com...
<?php if (0 == $totalRows_rsSearch) { echo "<h3>Sorry no products were found</h3>"; } else { echo "<h3>Please click on a product for further information.</h3>"; while ($row_rsSearch = mysql_fetch_assoc($rsSearch)){
    echo "<div class=\"productitem\"><img src=\"products\"".
$row_rsSearch['product_image']."
      <div class=\"text\">
        <h3>". $row_rsSearch['product_name']."</h3>
          <p class=\"style1\">". $row_rsSearch['product_subtitle'] ."
</p>
          <a href=\"products\"". $row_rsSearch['product_url']."View
Product</a>
        <div class=\"clear\"></div>
        </div> <div class=\"clear\"></div>
     <center>
        </center>
      </div>";
} } ?> is probably going to give you the result you want. However you should know it is bad practice to mix PHP and HTML as horridly as I just showed you. AKA you don't want your PHP writing your HTML. Anthony Gentile On Sun, Dec 21, 2008 at 1:07 PM, Gary Maddock-Greene < gmg@maddock-greene.co.uk> wrote:
I've corrected those errors thanks but how do I insert this code as the else statement? <?php do { ?>
     <div class="productitem"><img src="products<?php echo
$row_rsSearch['product_image']; ?>" />
       <div class="text">
         <h3><?php echo $row_rsSearch['product_name']; ?></h3>
           <p class="style1"><?php echo $row_rsSearch['product_subtitle'];
?></p>
           <a href="products<?php echo $row_rsSearch['product_url'];
?>">View Product</a>
         <div class="clear"></div>
         </div> <div class="clear"></div>
      <center>
         </center>
       </div>
<?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?> -- - Gary Maddock-Greene ""Anthony Gentile"" <asgentile@gmail.com> wrote in message news:2ce4207d0812210959k3491690ctbc4f0dbf971ac920@mail.gmail.com... ...missing semicolon and some brackets.
<?php if (0 == $totalRows_rsSearch) { echo "<h3>Sorry no products were found</h3>"; } else { echo "<h3>Please click on a product for further information.</h3>"; } ?> If there is more code you can show by perhaps pasting here: http://pastebin.redlinktech.com We can help with further syntax problems. Anthony Gentile On Sun, Dec 21, 2008 at 12:33 PM, Gary Maddock-Greene < gmg@maddock-greene.co.uk> wrote: Thanks guys .. I can get this part working great ..
<?php if (0 == $totalRows_rsSearch) { echo "<h3>Sorry no products were found</h3>"; } else echo "<h3>Please click on a product for further information.</h3>" ?> But I want to add the following so that only the products table appears when product are present. I cannot seem to add this code into the above after the echo "<h3>Please click on a product for further information.</h3>". I can't get the syntax right ... I appreciate everyones help -- - Gary Maddock-Greene "Ashley Sheridan" <ash@ashleysheridan.co.uk> wrote in message news:1229878234.4229.12.camel@localhost.localdomain... On Sun, 2008-12-21 at 11:39 -0500, Anthony Gentile wrote:
if (0 == $totalRows_rsSearch) {
echo "Sorry no products were found"; } else Anthony Gentile On Sun, Dec 21, 2008 at 11:22 AM, Gary Maddock-Greene < gmg@maddock-greene.co.uk> wrote:
I have tried that but to no avail :) <?php if ($totalRows_rsSearch=0) echo "Sorry no products were found"; else // All seems OK to here, then the syntax error unexpected T_VARIABLE appears echo <h3>Please click on a product for further information.</h3> <?php do { ?>
     <div class="productitem"><img src="products<?php echo
$row_rsSearch['product_image']; ?>" />
       <div class="text">
         <h3><?php echo $row_rsSearch['product_name']; ?></h3>
           <p class="style1"><?php echo >
$row_rsSearch['product_subtitle'];
?></p>
           <a href="products<?php echo $row_rsSearch['product_url'];
?>">View Product</a>
         <div class="clear"></div>
         </div> <div class="clear"></div>
      <center>
         </center>
       </div>
<?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?> -- - Gary Maddock-Greene "Ashley Sheridan" <ash@ashleysheridan.co.uk> wrote in message news:1229875150.4229.9.camel@localhost.localdomain... On Sun, 2008-12-21 at 15:40 +0000, Gary Maddock-Greene wrote:
Thanks Ashley ... I have been trying that but I think my syntax id shot!! <?php if ($totalRows_rsSearch="0") echo "Sorry no products were found"; else echo "<h3>Please click on a product for further information.</h3>" ?> <!-- Product block start search results -->
     <?php do { ?>
     <div class="productitem"><img src="products<?php echo
$row_rsSearch['product_image']; ?>" />
       <div class="text">
         <h3><?php echo $row_rsSearch['product_name']; ?></h3>
           <p class="style1"><?php echo
$row_rsSearch['product_subtitle']; ?></p>
           <a href="products<?php echo >>>
$row_rsSearch['product_url'];
?>">View Product</a>
         <div class="clear"></div>
         </div> <div class="clear"></div>
      <center>
         </center>
       </div>
<?php } while ($row_rsSearch = mysql_fetch_assoc($rsSearch)); ?> -- - Gary Maddock-Greene "Ashley Sheridan" <ash@ashleysheridan.co.uk> wrote in message news:1229873521.4229.6.camel@localhost.localdomain...
On Sun, 2008-12-21 at 15:22 +0000, Gary Maddock-Greene wrote:
Hi, I'm very new to php. Please can someone point me in the
right
direction? I want to display a message: 'No Products Found' if my search
record
set returns no value. I think I need to be looking at this section of my code ... $query_rsSearch = sprintf("SELECT * FROM products WHERE >>> >>
product_name
LIKE %s", GetSQLValueString("%" . $colname_rsSearch . "%", "text")); $rsSearch = mysql_query($query_rsSearch, $sondia_lighting) or die(mysql_error()); $row_rsSearch = mysql_fetch_assoc($rsSearch); $totalRows_rsSearch = mysql_num_rows($rsSearch); ?> Thanks - Gary Maddock-Greene
Can you not just use the $totalRows_rsSearch value inside of an if statement? Ash www.ashleysheridan.co.uk
It might be because you're comparing the total to a string rather than a
number if ($totalRows_rsSearch="0") If you remove the quote marks, it should work. Ash www.ashleysheridan.co.uk
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
D'oh, not sure how I missed that one too, the double ==. No wonder it
wasn't working. Ash www.ashleysheridan.co.uk
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#284931) next »