Re: [PHP-DB] New to PHP/MySQL - Need help with images

2008-01-06 Thread Chris

Thomas wrote:
I'm attempting to make a table with one row and 3 columns holding three 
different images. I want each image URL to be called from my database. 
Everything is set-up in my database. When I use the following code, it 
places the same picture across the three columns and does this three 
times (creating three rows.) I want a different picture to be placed 
across the three columns and to have only one row. What can I do?



Here is the code:

$result = @mysql_query('SELECT image FROM specials');


You're only querying one database field here. If you want more than one 
image to be loaded from the database, you need to include more fields.


So you'll end up with something like this:


';

while ($row = mysql_fetch_assoc($result)) {
echo '';
echo '' . $row['image1'] . '';
echo '' . $row['image2'] . '';
echo '' . $row['image3'] . '';
echo '';
}
echo '';
?>


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] New to PHP/MySQL - Need help with images

2008-01-05 Thread Matt Anderton
how about like this:

echo "\n";
$result = @mysql_query("SELECT image FROM specials");
while($row = mysql_fetch_row($result)) {
   echo "\n";
}
echo "\n\n";

hope it helps!
matt

On Jan 5, 2008 4:51 PM, Thomas <[EMAIL PROTECTED]> wrote:

> I'm attempting to make a table with one row and 3 columns holding three
> different images. I want each image URL to be called from my database.
> Everything is set-up in my database. When I use the following code, it
> places the same picture across the three columns and does this three times
> (creating three rows.) I want a different picture to be placed across the
> three columns and to have only one row. What can I do?
>
> Here is the code:
>
> $result = @mysql_query('SELECT image FROM specials');
> $num=mysql_numrows($result);
> $i = 0;
> while ($i < $num) {
> $image=mysql_result($result,$i,"image");
> ?>
> 
> 
> 
> ">
> 
> 
> ">
> 
> 
> ">
> 
> 
>  $i++;
> }
> echo "";
> ?>
>
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


RE: [PHP-DB] New to PHP & mySQL

2002-08-25 Thread Mark Middleton


> The one thing I cannot get into my head is how can you tell the database
> that all the days between the "start" and "end" dates are booked.
> Also when
> people search for a caravan on a specific date and say they want it for 7
> day the database/PHP checks to see if the entire period is
> totally free for
> them and does not colide with another booking.

Ray, it looks like you've done some great work so far.  This one point that
you are struggling with may not be as difficult as you are imagining as
well.

When a potential customer is searching for availability, they are going to
have to select a start date and an end date for the period they are looking
to book.

Then, you just take those two dates, and compare them against the previous
bookings for the same villa...  (if you do it in one step, you can tell them
"those dates are not available" - if you perform it in two steps, you can
give the customer more information about whether the start date, or the end
date (or both) were the source of the conflict. )  i.e. if they want to book
the Healy on 4/10 - 4/20, it could tell them that it is not available until
4-15... instead of telling them that the dates "just won't work" - does that
make sense?

So, using your example, the Healy is booked from 4/1 - 4/15...

When a customer runs a query to find availability, they will select a
start_date of 4/10 and an end date of 4/20

(hehe, I just said 420...)

[one step method]

(of course convert the requested $start_date and $end_date into -MM-DD
format)

 '$start_date')
OR
(booking_start < '$end_date'
AND
booking_end > '$end_date'))
AND
villa_id = '$requested_villa_id'";

$query = mysql_query($sql);
$is_it_booked = mysql_fetch_object($query);
print "number of reservations during this date =
".$is_it_booked->how_many_booked;

?>

This checks if the start date is between the booked dates OR the end date is
between the booked dates
If rows are returned, then the dates are not available.

Does this help?

-Mark





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php