Jump to content

boney alex

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by boney alex

  1. Hi, is it possible to use the GET method to gather more than one id from a link? Ive got a table of vehicles that have been displayed according to a search. The important variables that I need to take to my next page are: $makemodelID, $branchID, $collectiondate, and $returndate. <td><a href=\"bookthisvan.php?id=$makemodelID\branch=$branchID\collection=$collectiondate\returndate=$returndate\">Book this Van!!!</a></td> At the moment all this seems to do is set the id to "$makemodelID\branch=$branchID\collection=$collectiondate\returndate=$returndate". Are there any ways around this? Cheers
  2. Hi Barand, yeah Ive sorted my first problem, for some reason I rearranged the query and put the WHERE clause above all the sub-queries and it worked fine. BUT you are right about that fourth condition, how would you write that as a sub-query if you dont mind me asking? cheers
  3. Hi, Im trying to write a complicated query and Im almost there!! Im building a vehicle rental website and Im working on a search facility whereby users can select a branch location, a collection date and a return date, and all vehicles that are available between those dates, and at that branch are displayed. My vehicles are of different 'makesandmodels'. The query looks at whether there is AT LEAST one vehicle of a certain makeandmodel available between the dates. However, my query always throws a record of NULL fields for the first record. It seems to throw this record of NULL fields for the first makemodel that isnt available between those dates and at that location. For example, if vehicle 3 is the only vehicle with makemodel 1 and vehicle 3 isnt available between the dates, the query will display 3 1 NULL NULL NULL NULL etc. BUT work thereafter. "SELECT Vehicle.MakeModelID, Vehicle.VehicleID, MakeandModel.Make, MakeandModel.Model, MakeandModel.Specification, MakeandModel.Engine, MakeandModel.Load_Options, MakeandModel.Extras, MakeandModel.DailyRate FROM Vehicle LEFT JOIN MakeandModel ON Vehicle.MakeModelID = MakeandModel.MakeModelID AND VehicleID NOT IN (SELECT VehicleID FROM Reservation WHERE '$collectiondate' BETWEEN Collection_Date AND Return_Date) AND VehicleID NOT IN (SELECT VehicleID FROM Reservation WHERE '$returndate' BETWEEN Collection_Date AND Return_Date) AND VehicleID NOT IN (SELECT VehicleID FROM Rental WHERE '$collectiondate' BETWEEN Collection_Date AND Return_Date) AND VehicleID NOT IN (SELECT VehicleID FROM Rental WHERE '$returndate' BETWEEN Collection_Date AND Return_Date) AND VehicleID NOT IN (SELECT VehicleID FROM Reservation WHERE Collection_Date AND Return_Date BETWEEN '$collectiondate' AND '$returndate') AND VehicleID NOT IN (SELECT VehicleID FROM Rental WHERE Collection_Date AND Return_Date BETWEEN '$collectiondate' AND '$returndate') WHERE Vehicle.BranchID = '$branchID' GROUP BY MakeandModel.MakeModelID ORDER BY MakeandModel.DailyRate"
  4. Hi, Im trying to print out a table of vehicle information. Each vehicle record has an image (picture of the vehicle) associated with it. I have named each image the ID of the makemodel. Ive got a while loop which runs through the records and prints them out in a table, but Im struggling to display the image for each record. <table width="300" border="0" cellspacing="10"> <? while ($van = mysql_fetch_array($query)) { $makemodelID = $van['MakeModelID']; $make = $van['Make']; $model = $van['Model']; $spec = $van['Specification']; $vantype = $make. " " .$model. " " .$spec; $loadoptions = $van['Load_Options']; $engine = $van['Engine']; $extras = $van['Extras']; echo (" <tr> <td>Van:</td> <td>$vantype</td> <td rowspan="4"><img src="Images/$makemodelID.gif"></td> </tr> <tr> <td>Load Options:</td> <td>$loadoptions</td> </tr> <tr> <td>Engine:</td> <td>$engine</td> </tr> <tr> <td>Extras:</td> <td>$extras</td> </tr>"); } ?> </table> Obviously the problems lies somewhere around this line of code: <td rowspan="4"><img src="Images/$makemodelID.gif"></td> Any hints/ideas? Thank you.
  5. think ive sorted it, I just added a GROUP BY clause
  6. Hi, im in the process of writing a query but Im struggling to return the results Im after. Ive got two tables, vehicle and makeandmodel, and im trying to display a distinct row with regards to the make and model. For example, two vehicles may have the same make and model, but I only want to output one of those two records. My query so far is: SELECT Vehicle.VehicleID, Vehicle.MakeModelID FROM Vehicle LEFT JOIN MakeandModel ON Vehicle.MakeModelID = MakeandModel.MakeModelID The output Im gettin at the mo is VehicleID MakeModelID 1 3 2 3 3 1 4 2 5 4 6 4 Where two vehicles have the same make and model ( vehicles 1 and 2 AND 5 and 6), I only want the first record, so does LIMIT have to be used???
  7. Hi, I've got three buttons on a page and basically all I'm trying to do is put a BACK button as one of the three. But I'm having difficulties getting it to work. <form name="reservationinfo" action="reservationcollected.php" method="post"> <input type="hidden" name="reservationID" value="<? echo $reservationID; ?>"> <center> <table width="400" border="0" cellspacing="5"> <tr> <td><input type="submit" value= "Reservation Collected" class="button" name="submit"></td> <td><input type="submit" value='Cancel Reservation' onclick="reservationinfo.action='admincancelreservation.php'; return true;"></td> <td><input type="submit" value='Back' onclick="reservationinfo.action='history.go(-1)'; return true;"></td> </tr> </table> </center> </form> The solutions Ive been trying either take me to reservationcollected.php OR says history.go(-1) CANNOT BE DISPLAYED. Any ideas? Cheers
  8. Ive got this function which checks the username contains only letters and numbers and is between 6-12 characters long. How do I change this function to only allow letters and spaces and be of any length? <? function usernamecheck($username) { if (eregi ("^[[:alnum:]]{6,12}$", $username)) { return true; } else { return false; } } ?> Cheers
  9. I have a PHP calendar with each day as a link that the user can click on. To keep in line with the colours of my site I have made the links (dates) YELLOW and the background red. Below the calendar in the same page, I have a table which is populated by records from a table in my database. Each record has a reservationID which I have made a link aswell. Is there anyway to make these links in the table standard blue but keep my dates in yellow? I have made the dates yellow by using: <body bgcolor="#FFFFFF" link="#FFFF00" vlink="#FFFF00"> This is the line of code which shows the reservationID link: <td> <center><font face=Arial size=2><a href=\"reservationinfo.php?id=$reservationID\">$reservationID</a></font></center> Any ideas would be much appreciated.
  10. I have a PHP calendar with each day as a link that the user can click on. To keep in line with the colours of my site I have made the links (dates) YELLOW and the background red. Below the calendar in the same page, I have a table which is populated by records from a table in my database. Each record has a reservationID which I have made a link aswell. Is there anyway to make these links in the table standard blue but keep my dates in yellow? I have made the dates yellow by using: <body bgcolor="#FFFFFF" link="#FFFF00" vlink="#FFFF00"> This is the line of code which shows the reservationID link: <td> <center><font face=Arial size=2><a href=\"reservationinfo.php?id=$reservationID\">$reservationID</a></font></center> Any ideas would be much appreciated.
  11. Does anyone know how to highlight the current date in my calendar code?
  12. Ive found a simple calendar that displays all the days of the month as a link. I have saved the code below as eventcalendar.php and what I would like is when the user selects a certain day, that will take them to a page saved as eventinfo.php with the events for that day. I have managed to point each link to eventinfo.php, I'm just struggling to pass the actual date to that page, any ideas?? <?php mk_drawCalendar($_GET['m'],$_GET['y']); ?> </blockquote> </body> </html> <?php //********************************************************* // DRAW CALENDAR //********************************************************* function mk_drawCalendar($m,$y) { if ((!$m) || (!$y)) { $m = date("m",mktime()); $y = date("Y",mktime()); } /*== get what weekday the first is on ==*/ $tmpd = getdate(mktime(0,0,0,$m,1,$y)); $month = $tmpd["month"]; $firstwday= $tmpd["wday"]; $lastday = mk_getLastDayofMonth($m,$y); ?> <table cellpadding="2" cellspacing="0" border="1"> <tr><td colspan="7" bgcolor="#CCCCDD"> <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr><th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m-1)<1) ? 12 : $m-1 ?>&y=<?=(($m-1)<1) ? $y-1 : $y ?>"><<</a></th> <th><font size=2><?="$month $y"?></font></th> <th width="20"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?m=<?=(($m+1)>12) ? 1 : $m+1 ?>&y=<?=(($m+1)>12) ? $y+1 : $y ?>">>></a></th> </tr></table> </td></tr> <tr><th width=22 class="tcell">Su</th><th width=22 class="tcell">M</th> <th width=22 class="tcell">T </th><th width=22 class="tcell">W</th> <th width=22 class="tcell">Th</th><th width=22 class="tcell">F</th> <th width=22 class="tcell">Sa</th></tr> <?php $d = 1; $wday = $firstwday; $firstweek = true; /*== loop through all the days of the month ==*/ while ( $d <= $lastday) { /*== set up blank days for first week ==*/ if ($firstweek) { echo "<tr>"; for ($i=1; $i<=$firstwday; $i++) { echo "<td><font size=2> </font></td>"; } $firstweek = false; } /*== Sunday start week with <tr> ==*/ if ($wday==0) { echo "<tr>"; } /*== check for event ==*/ echo "<td class='tcell'>"; echo "<a href=\"eventinfo.php\" onClick=\"eventdate.value='$d-$m-$y';\">$d</a>"; echo "</td>\n"; /*== Saturday end week with </tr> ==*/ if ($wday==6) { echo "</tr>\n"; } $wday++; $wday = $wday % 7; $d++; } ?> </tr></table> Click on a date to select it and to populate the event date field on the left <br /> <?php /*== end drawCalendar function ==*/ } /*== get the last day of the month ==*/ function mk_getLastDayofMonth($mon,$year) { for ($tday=28; $tday <= 31; $tday++) { $tdate = getdate(mktime(0,0,0,$mon,$tday,$year)); if ($tdate["mon"] != $mon) { break; } } $tday--; return $tday; } ?> I think that the problem lies somewhere around this line: echo "<a href=\"eventinfo.php\" onClick=\"eventdate.value='$d-$m-$y';\">$d</a>"; Thanks for any help.
  13. Yeah, I've been trying that but they all seem to be large zip files that are downloaded and are fairly impossible to customised to your needs
  14. Hi, Im trying to add an event's calendar to my website. I have spent all day trying to get Obsidian's php event calendar to work but with no success at all. What I need is something very very similar to the birthday calendar available from the top nav bar of this forum. I have a reservation table with reservations that have a 'CollectionDate' and a 'ReturnDate'. I'd like to display each record on both of those dates. Any advice/tips/ knowledge of a good script and its whereabouts would be fantastic! Cheers
  15. Yeah I was looking at that but was struggling to make much sense of it
  16. returns only the numbers within a string?? The reason I ask is because I'm asking the user to enter data such as 1200mm and £9.28. I only want to insert into my database 1200 and 9.28 respectively. Thanks.
  17. Hi, I've got two drop down menus that I'm using to filter some data. It works when the user selects an option from both menus but always return ZERO records when only one of out the two menus have been set. My code POSTS the ID from each menu then puts that ID into the WHERE clause of an SQL query. <?php $makemodelID = $_POST['vantype']; $branchID = $_POST['branch']; if($query= mysql_query("SELECT VehicleID, Registration, Make, Model, Specification, Colour, Mileage, Transmission, Branch_Name FROM Vehicle LEFT JOIN MakeandModel ON MakeandModel.MakeModelID = Vehicle.MakeModelID LEFT JOIN Branch ON Vehicle.BranchID = Branch.BranchID WHERE Vehicle.MakeModelID = '$makemodelID' AND Vehicle.BranchID = '$branchID' ORDER BY Make, Model, Specification, Mileage")) ?> I think the problem lies with the makemodelID = ' ' or the branchID = ' ', which automatically returns no records. Is there anyway around this? Cheers
  18. Cheers boo_lolly, works a threat! Thanks!
  19. thanks mate, that works great for my HTML populated drop down, BUT how would you go about keepin selections if the drop down list was populated from a table in your MySQL database??????? For example: <?php $result = mysql_query("SELECT BranchID, Branch_Name FROM Branch ORDER BY Branch_Name"); ?> <label for="branch">Branch:</label> <select name="branch" STYLE="width: 220px" size="0"> <option selected value=""></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option value=\"{$row[branchID]}\">{$row[branch_Name]}</option>\n"; } ?>
  20. Hi, I making an 'Add New Vehicle' feature using drop down lists for some of the data entry. If there is a probelm with the data entry such as a null field then the form is shown with all the previous entered data. How do I show what option has already been selected in a drop down list? newvan.php <form name="newvan" action="addnewvehicle.php" method="post"> <fieldset> <legend>Vehicle Information</legend> <label for="registration">Registration:</label> <input type="text" input id="registration" name="registration" size="10"><br><br> <?php $result = mysql_query("SELECT MakeModelID, Make, Model, Specification FROM MakeandModel ORDER BY Make, Model, Specification"); ?> <label for="branch">Type of Van:</label> <select name="vantype" STYLE="width: 220px" size="0"> <option selected value=""></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option value=\"{$row[MakeModelID]}\">{$row[Make]} {$row[Model]} {$row[specification]}</option>\n"; } ?> </select><br><br> <?php $result = mysql_query("SELECT BranchID, Branch_Name FROM Branch ORDER BY Branch_Name"); ?> <label for="branch">Branch:</label> <select name="branch" STYLE="width: 220px" size="0"> <option selected value=""></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option value=\"{$row[branchID]}\">{$row[branch_Name]}</option>\n"; } ?> </select><br><br> <label for="colour">Colour:</label> <input type="text" input id="colour" name="colour" size="20"><br><br> <label for="mileage">Mileage (e.g. 55000):</label> <input type="text" input id="mileage" name="mileage" size="10"><br><br> <label for="transmission">Transmission:</label> <select name="transmission" STYLE="width: 90px" size="0"> <option selected value=""></option> <option value="Manual">Manual</option> <option value="Auto">Automatic</option> </select><br> </fieldset> <br> <center><input type="submit" value= "Add Vehicle" class="button" name="submit"></center> </form> I can show the normal text fields by POSTING the value into a variable and echo in the value: <label for="registration">Registration:</label> <input type="text" input id="registration" name="registration" size="10" value="<? echo $registration; ?>"><br><br> <label for="colour">Colour:</label> <input type="text" input id="colour" name="colour" size="20" value="<? echo $colour; ?>"><br><br> <label for="mileage">Mileage (e.g. 55000):</label> <input type="text" input id="mileage" name="mileage" size="10" value="<? echo $mileage; ?>"><br><br> Thanks for any help
  21. Hi all, very new to PHP and I've got a dead simple question. Ive managed to display my records in a table, with a link called 'Cancel' next to get row. When the user selects cancel I would like to open cancel.php and gather all the information regarding the ID for that row. I have the following code: <?php while ($reservation = mysql_fetch_array($query)) { $reservationid = $reservation['ReservationID']; $make = $reservation['Make']; $model = $reservation['Model']; $spec = $reservation['Specification']; $collectiondate = $reservation['Collection_Date']; $returndate = $reservation['Return_Date']; $cost = $reservation['Cost']; echo (" <tr> <td> <font face=Arial>$reservationid</font> </td> <td> <font face=Arial>$make</font> </td> <td> <font face=Arial>$model</font> </td> <td> <font face=Arial>$spec</font> </td> <td> <font face=Arial>$collectiondate</font> </td> <td> <font face=Arial>$returndate</font> </td> <td> <font face=Arial>$cost</font> </td> <td> <a href=\"cancel.php?id=$reservationid\">Cancel</a> </td> </tr> ?> On cancel.php, how do I get the id=$reservationid??? Thanks
  22. thanks btherl think ive sorted it using a very similar query: SELECT * FROM Vehicle WHERE BranchID = '1' AND MakeModelID = '3' AND VehicleID NOT IN ( SELECT VehicleID FROM Reservation WHERE '2007-04-03' BETWEEN Collection_Date AND Return_Date) Both seem to return identical results. Thanks for your help!!!
×
×
  • 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.