Jump to content

Tychonaut

Members
  • Posts

    8
  • Joined

  • Last visited

Tychonaut's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Reeeeeeeaaaaallly not so easy to find the "Forum Rules" link way down there. But I got it.
  2. Depending on the situation and how comfortable you are with jQuery there is an interesting JQ/PHP package called "imageAreaSelect" which allows the user to "draw out" a square on their original photo as they upload it. jQuery updates hidden fields on the photo upload form with the coordinates of this selected area, and then this is passed back to PHP when the form is submitted. These coordinates are then used in the cropping and resizing process. You just assign the final thumbnail size and "selection aspect ratio" as constants. (ie a square is 1:1) Essentially they are selecting out their own thumbnail when they upload their photo. It gets around the "how do I crop an image that will accommodate all different photo compositions?" problem. It's not too hard to implement. Even if you don't use it, the code is worth taking a look at.
  3. I wasn't sure that all posted code had to be useable *as is*. I will watch for that in the future. I guess my uncommented ".. etc .." was a baddie as well? Sorry.. I'm new here. Of course, it wouldn't be hard to get monospace code formatting going on the posts, right? On a site for code t'would be a nice "extra".
  4. You are of course right. Thats why I said the silly var names are for "educational purposes only" .. I just wanted them to be self explanatory, and I find the font spacing here reeeeeeaaallllly tiny, so I spaced the names out a bit. I_should_have_used_underscores.
  5. Joins can take a bit to understand, but eventually you will be dynamically generating a query like this (this would allow you to get customer info, his order info, and the description of the item he ordered .. contained in 3 separate tables) SELECT tableA.name, tableA.address, tableA.email, tableB.orderID, tableB.orderTotal, tableC.itemDescription FROM tableA INNER JOIN tableB // add access to tableB ON tableA.customerID = tableB.customerID // where they share this value in common INNER JOIN tableC ON tableB.productID = tableC.productID WHERE tableA.customerID = '47655'; This allows you to grab information from multiple tables in the same query. You just have to make sure that there is a "shared column" or "foreign key" in common between the two tables. You are saying.. "give me the fields from tableA .. *plus* give me access to the fields in tableB where "field X" is the same as in the first table. There are a few different kinds of JOIN statements, but that is probably the one you will use the most.
  6. It's kind of confusing what you are asking. What would be a keyword that someone would search for? If I search for "math" .. how would cities show up for that? Or am I searching for cities .. "London" .. and then the tutors in London are showing? It seems like you have 4 categories that would not have results for a single keyword. What one word would give me relevant tutors, institutes, subjects, and cities? I think the whole logic could be re-thought to make your problem easier.
  7. If the pics are always going to have the standard name format of "item".png, you could do this $availableItemsArray = ("socks", "jacket", "hat", "boxers"); $testItemsArray = ("jacket", "boxers", "monkey hair gloves", "socks", "jodhpurs"); $arrayLength = count($itemsArray); // you could put this in the for loop below .. but its better to only count the array one time and save it, than to count it on each iteration for($i=0; i < $arrayLength; $i++){ if(in_array($testItemsArray[ $i ], $availableItemsArray) // grabs each item to be compared one by one .. and looks if it is in the array of available items { echo "images/" . $testItem[ $i ] . ".png"; }else{ echo "Item doesn't exist"; } } You might want to put a strtolower() in there somewhere to deal with capitalization discrepencies
  8. Ugh. Getting a headache looking at the code. I'm not sure exactly what you are trying to do, but you could also use this idea maybe? Basically build your 2 columns *beforehand* ... and then deposit each item one by one, switching back and forth with your modulo operator. (Silly var names for educational purposes only) <?php // set up your empty column HTML string holders $col-A-html-string = ""; $col-B-html-string = ""; while ($record = mysql_fetch_object($result)) { // build each item (we are staying inside PHP here) $item-html-string = ""; $item-html-string .= "<h2>" . $record->title . "</h2>"; $item-html-string .= "<p>" . $record->info . "</p>"; ..etc... // flip flop and deposit each item into one or other of the holders if ($count++ % 2 == 0) { $col-B-html-string .= $item-html-string; } else{ $col-A-html-string .= $item-html-string; } } ?> // finally drop the column string vars into the appropriate locations <div class="col-A"><?php echo col-A-html-string ?></div> <div class="col-B"><?php echo col-B-html-string ?></div>
×
×
  • 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.