Jump to content

cootetom

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by cootetom

  1. Ok, I have run the code you gave me and found that my server does not infact have the mysqli function support. It is running PHP version 4.However I have used the information from that handy link you gave me and got my code working. I have decided to read through the book I have and then change any examples I want to try to use the mysql functions instead. This will work out to my advantage as I will be learning about both sets of functions, plus it will make me think a little more!Thanks for the advice on my database designs I will certainly be using the idea. Also thanks for such a details response, now I can get on with learning MySQL.- Tom
  2. Hey all, I'm learning how to use mySQL reading a book called 'PHP and MySQL Web Development' by Luke Welling & Laura Thomson. I'm working through an example but have become stuck! I've set up the database on my server hosted by streamline.net which looks like this;Customers(CustomerID, Name, Address, City)Orders(OrderID, CustomerID, Amount, Date)Books(ISBN, Author, Title, Price)Order_Items(OrderID, ISBN, Quantity)Book_Reviews(ISBN, Reviews)I then setp up a small form on a web page to query this database. <form id="search" action="results.php" method="post"> <p> <label for="searchtype">Search by: </label> <select name="searchtype" id="searchtype"> <option value="author">Author</option> <option value="title">Title</option> <option value="isbn">ISBN</option> </select> </p> <p> <label for="searchterm">Search term: </label> <input name="searchterm" id="searchterm" type="text" /> </p><p> <input type="submit" id="submit" value="Search" /> </p></form> But the code in my php file doesn't seem to be connecting to the database. <?php //create short variable names $searchType = $_POST['searchtype']; $searchTerm = $_POST['searchterm']; $searchTerm = trim($searchTerm); if (!$searchType || !$searchTerm) { echo 'You have not entered search details. Please go back and try again.'; exit; } if (!get_magic_quotes_gpc()) { $searchType = addslashes($searchType); $searchTerm = addslashes($searchTerm); } @ $db = mysqli_connect('mysql8.streamline.net', 'tomcootec', 'mypassword', 'tomcootec'); if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from books where ".$searchType." like '%".searchTerm."%'"; $results = mysqli_query($db, $query); $num_results = mysqli_num_rows($results); echo '<p>Number of books found: '.$num_results.'</p>'; for ($i=0; $i < $num_results; $i++) { $row = mysqli_fetch_assoc($results); echo '<p><strong>'.($i+1).'Title: '; echo htmlspecialchars(stripslashes($row['title'])); echo '</strong><br />Author: '; echo stripslashes($row['author']); echo '<br />ISBN :'; echo stripslashes($row['isbn']); echo '<br />Price: '; echo stripslashes($row['price']); echo '</p>'; } mysqli_free_result($results); mysqli_close($db);?> If I take away the error suppression operator '@' from the line when connecting i get the following error. Can anyone give me some help on this one?Thanks- Tom
  3. Thats great I can see where I was making mistakes so thanks.The built in array.sort() method won't work here as far as I know becuase i want to sort the array by a property of the object in it. The array.sort() will convert the object to a value so will take into account all other properties as well. Atleast thats my understanding of it.I'm learning javascript at the moment and am used to java but it's going well. I like some of the advantages to the looseness of the language but sometimes it makes it hard to code initially.- Tom
  4. Hey all, i'm trying to sort an array of objects. I want to sort them into order of an object property named 'vendor', which is a string. I'm using a sorting algorithm that i use in java and have never tried in javascript so i don't know if it works. The few questions i have are;- Does javascript allow recursive calls?- If i compare strings like (array.vendor <= anotherstring) will this work?- To swap i have created a temporary object. Can i simply say tempObject = array ?Anyways you can view my code at the link below so you can see why i'm asking these questions. At the moment it does nothing when i call this function so i'm assuming some error somewhere. By the way i have an array of objects called 'inspectedCars' which includes a property called 'vendor' globally. I'm calling this function with 0 and inspectedCars.length so that it will sort the whole array, if i ever getting it working.sortList Function CodeAny help appreciated.- Tom
  5. cootetom

    Class's

    Thanks for the responses.border: 0; has worked fine. I didn't realise IE doesn't like the hidden keyword! Oh well something learnt at least.- Tom
  6. cootetom

    Class's

    I'm having different results with my css code in different browsers. I have a class in my css file that hides borders etc and have written it like this: Now I use this class within the <table> and <td> tags to effectively hide them like this: In firefox i get the results i want i.e. a table with no borders! However this does not work in IE, it just ignores the class and defaults to my normal table styling with borders. Does anyone know why this is and how I can fix it?- Tom
×
×
  • Create New...