Jump to content

phplee

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

phplee's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. does anyone know the code that i would need to limit information from a database (MYSQL) so.. if i was listing hotels and wanted to put them on seperate pages, 5 stars on one page and 4 stars on another and so on, what do i need to do to get this??? is it something to do with $query = "SELECT * FROM MYTABLE ORDER BY AA_Rating DESC LIMIT"; $result = mysql_query($query) or die("Error: " . mysql_error()); this selects all my info from the database, what needs to be changed or added so i only get 5 star hotels. regards phplee
  2. hi, i need some help to get php to work in an echo, i have this to display a list of hotels by there star rating, this is the code i have... $text = ("<p> <font face='Verdana' size='2'><img src='http://www.mydomain.com/photos/$Hotel_Id/AAB$Hotel_Id.jpg' alt='$Establishment_Name' width='100' height='75'><br> <a href='$Home_Hyperlink'>$Establishment_Name</a><br> $Address1 $Address2 $Town $Post_Code<br> $Description<br> Click here to book the <a href='$Bookings_Hyperlink'>$Establishment_Name</a><br> This hotel has a $AA_Rating Star AA rating, and a $RAC_Rating star RAC rating</font> </p><br> "); but some of them dont have a star rating so i want to put an if statement arround them, here is the code i tried but it does not show up when i upload it? ... This hotel has a <?php if ($AA_Rating == '0') { echo 'this hotel does not have a AA rating'; } else { echo '$AA_Rating ' ?> </font> </p><br> ... the same for rac, i dont know if explained this enough, recap... this is a php page and i want to put more php in it (shown above) any help much appreciated!!!!! regards phplee
  3. <?php my connections are here! ...... // create the SQL statement $sql = "SELECT * FROM Manchester ORDER BY EstablishmentName ASC"; // execute the SQL statement $result = mysql_query($sql, $conn) or die(mysql_error()); //go through each row in the result set and display data while ($newArray = mysql_fetch_array($result)) { // give a name to the fields //echo the results onscreen echo "<p><img src='http://www.mydomain.com/photos/$Hotel_Id/AAB$Hotel_Id.jpg' alt='$EstablishmentName' width='100' height='75'><br> <a href='$Homehyperlink'>$EstablishmentName</a><br> $Address1 $Address2 $Town $Postcode<br><br> $Description<br> Prices from £$Rooms_From. </p>"; } // If current page number, use it // if not, set one! if(!isset($_GET['testall'])){ $page = 1; } else { $page = $_GET['testall']; } // Define the number of results per page $max_results = 8; // Figure out the limit for the query based // on the current page number. $from = (($page * $max_results) - $max_results); // Perform MySQL query on only the current page number's results $sql = mysql_query("SELECT * FROM Manchester LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){ // Build your formatted results here. echo $row['title']."<br />"; $Hotel_Id = $newArray['Hotel_Id']; $Homehyperlink = $newArray['HomeHyperlink']; $Address1 = $newArray['Address1']; $Address2 = $newArray['Address2']; $Postcode = $newArray['PostCode']; $Town = $newArray['Town']; $County = $newArray['County']; $Description = $newArray['Description']; $EstablishmentName = $newArray['EstablishmentName']; $Rooms_From = $newArray['Rooms_From']; } // Figure out the total number of results in DB: $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM Manchester"),0); // Figure out the total number of pages. Always round up using ceil() $total_pages = ceil($total_results / $max_results); // Build Page Number Hyperlinks echo "<center>Select a Page<br />"; // Build Previous Link if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i "; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } // Build Next Link if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a>"; } echo "</center>"; ?> please can anyone help fix the problems in this code so that i get a list of 8 hotels then it goes on to the next page and so on. at the moment it creating a page with all the hotels on it, and the prev, next, are at the bottom of the page, but they are not working please help me!!!! if you do not understand anything leave a reply and i will try to explain it a bit more! Thank you very mch lee
  4. i am trying to sort data that i am getting from a mysql database in alphabetical order, does anyone know what strip of code i might use to do this? e.g. $Description = $newArray['Description']; $EstablishmentName = $newArray['EstablishmentName']; echo "$EstablishmentName, $Description this gives me a list, can i sort it? any help much appreciated thanks lee
  5. <?php $ans = $_POST[first] $_POST[calc] $_POST[second]; $message = ""; if (!isset($_POST[first]) == here) { $message = "Welcome to the math machine"; } elseif (($_POST[first]) == ($_POST[first])) { $message = "$_POST[first] $_POST[calc] $_POST[second] = $ans"; } ?> this a peice of code from a test page i am trying out. $_POST[first] $_POST[calc] $_POST[second]; these are user inputs, they would make, E.G. 4 + 4, i want this to complete so that when i put $ans in my code it will give me 8, not 4 + 4. any help on this matter will help me very much, and is much apreciated. thanks loads lee
×
×
  • 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.