Re: [PHP-DB] New to PHP/MySQL - Need help with images
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: ?php $query = select image1, image2, image3 from specials; $result = mysql_query($query); echo 'table'; while ($row = mysql_fetch_assoc($result)) { echo 'tr'; echo 'td' . $row['image1'] . '/td'; echo 'td' . $row['image2'] . '/td'; echo 'td' . $row['image3'] . '/td'; echo '/tr'; } echo '/table'; ? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] New to PHP/MySQL - Need help with images
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); ? table tr td img src=? echo $image; ? /td td img src=? echo $image; ? /td td img src=? echo $image; ? /td /tr ? $i++; } echo /table; ? -- 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 - Need help with images
how about like this: echo table\ntr; $result = @mysql_query(SELECT image FROM specials); while($row = mysql_fetch_row($result)) { echo tdimg src= . $row[0] . //td\n; } echo /tr\n/table\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); ? table tr td img src=? echo $image; ? /td td img src=? echo $image; ? /td td img src=? echo $image; ? /td /tr ? $i++; } echo /table; ? -- 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
[PHP-DB] New to PHP mySQL
Hi all (details of database at then end of this message) I hope someone can give me some advice. I am trying to create a database and access via PHP for a friend of mine that has a caravan park. What I want him to be able to do is to add bookings for the caravans via a PHP page and for clients to be able to search to see if a caravan is available for rent. I have created 2 tables and have put data into it via command prompt and also retrieved the data from it and carried out a join linking the 2 tables together. Which all seems to work well. 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. I am not sure whether I should be in list list of the PHP list so sorry if I have got it wrong. Any advice or places to visit would be greatly appreciated. Thanks for all your help Ray Details of what i have done already: mysql use matrix Database changed mysqlCREATE TABLE bookings ( - booking_id SMALLINT (6) NOT NULL AUTO_INCREMENT, - booking_start DATE NOT NULL DEFAULT '-00-00', - booking_end DATE NOT NULL DEFAULT '-00-00', - villa_id SMALLINT (6) NOT NULL DEFAULT '0', - PRIMARY KEY (booking_id) - ); mysqlINSERT INTO bookings VALUES (1, '2002-04-01', '2002-04-15', 3); mysqlINSERT INTO bookings VALUES (2, '2002-03-23', '2002-04-04', 1); mysqlCREATE TABLE villas ( - villa_id SMALLINT (6) NOT NULL AUTO_INCREMENT, - vill_name VARCHAR (25) NOT NULL DEFAULT '', - PRIMARY KEY (villa_id) - ); mysqlINSERT INTO villas VALUES (1, 'Gandy'); mysqlINSERT INTO villas VALUES (2, 'Hathaway'); mysqlINSERT INTO villas VALUES (3, 'Healy'); mysqlINSERT INTO villas VALUES (4, 'Mcleod'); mysql SELECT * FROM bookings; ++---+-+-+ | booking_id | booking_start | booking_end | villa_id | ++---+-+-+ | 1 | 2002-04-01 | 2002-04-15 |3 | | 2 | 2002-03-23 | 2002-04-04 |1 | ++---+-+-+ 2 rows in set (0.17 sec) mysql SELECT * FROM villas; +--++ | villa_id | villa_name | +--++ |1| Gandy| |2| Hathaway | |3| Healy | |4| Mcleod | +--++ 4 rows in set (0.00 sec) mysql SELECT villa_name, booking_start, booking_end FROM bookings LEFT JOIN villas ON bookings.villa_id = villas.villa_id; ++---++ | villa_name | booking_start | booking_end | ++---++ | Healy | 2002-04-01 | 2002-04-15 | | Gandy | 2002-03-23 | 2002-04-04 | ++---++ 2 rows in set (0.00 sec) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] New to PHP mySQL
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) ?php $startsql =SELECT count(*) as how_many_booked FROM bookings WHERE ((booking_start '$start_date' AND booking_end '$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
[PHP-DB] new user php/mysql problem
When I create a new user with grant I am able to access mysql with the new user through the command line and by applications like mysqlfront, however I am not able to connect with php. Does anybody have an idea of how to correct this? Thanks Ted Kappes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] new user php/mysql problem
It may be an issue with the connect from host for that user. That's the only thing I can come up with. Is your web server the same machine as your MySQL server? Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, May 06, 2002 9:47 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] new user php/mysql problem When I create a new user with grant I am able to access mysql with the new user through the command line and by applications like mysqlfront, however I am not able to connect with php. Does anybody have an idea of how to correct this? Thanks Ted Kappes -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php