PHP recipe for mysql db dictionary-like lookup?

tench

Registered
Hi there.

I was wondering if you knew of any PHP recipe/tutorial out there that could teach somebody who doesn't know much PHP to use it to look up and display mySQL records on a web page.

To be more precise, I want to be able to learn how to write a PHP script which will work like this: you click on a word on the webpage, it looks it up in the mysql db and displays its translations in in a popup.

This is, I'm sure, pretty simple in PHP, but I'd like to find a tutorial. It would be ideal if the db lookup would allow the display of multiple records from multiple tables based on their ID's...

Anyway... I do NOT expect anybody to offer me a full-blown solution to my problem, but I hope there's some info out there about this kind of stuff. I have looked, but in vain.

peace,
tench
 
You can't go wrong with W3Schools... http://www.w3schools.com/php/default.asp

These are the best on-line FREE tutorials. I presume you want to start from scratch. It also has a MySQL tutorial set.

If your hand-coding, this, and a couple of decent books (Sams 24hr or O'Reilly) should kick you off. However, even though I no longer use it, Dreamweaver does have good support for PHP-MySQL development, and initially makes it easier.
 
The book that got me going was Beginning PHP4 by Wrox Publishing.

It covers not only PHP, but provides a good introduction to MySQL as well as some of the libraries that come with PHP, like creating dynamic graphics, ODBC connections et cetera.

I highly recommend that book...
 
Well, one idea would be something like this (the code is not 100% correct, but you could lookup stuff based on the idea, I don't have my Javascript reference handy).

The word you want to translate would be a link (maybe disguised to not look like a link) that would be something like this:

< a href="#" onclick="javascript.load.new.window.with.contents.of('popup.php?wordvar=Hello');" > Hello < /a >

Then in popup.php you would use the GET variable that you passed with ?wordvar=Hello something like this:

<?php
$wordToFind = $_GET['wordvar'];

'connect to database

'run mysql query statement using "select * from WordTable where WordTable = '$wordToFind' "

'you'll get an array of results and depending on which PHP function you use it may be organized by table name. you'll probably won't need a loop, so you can then just output the contents with something like:

?>

<html>

<body>
<?=$result['WordTable'] ?>

</body>

</html>


This probably isn't very clear, I would actually try it out myself, but I don't currently have my mySQL db runnning on my server.


A good mySQl intro book is the new "MySQL Tutorial" (has the mySQL logo on it) and I learned PHP from the online docs and "PHP and MySQL Web Developement 2nd ed."


*edit*

Actually, if you'll have a word in multiple languages, you will need a loop to go throw the list of results that the query returns. If I get a chance to refresh my memory I'll try to post some real code that might actually be helpful. :)
 
hey guys!
sorry for the delay in responding, i was unexpectedly away for a few days. many thanks for your book tips and the code provided by btoth. i haven't tested it yet, but i'm looking forward to playing with it.

(I will probably come back crying, when i can't figure things out, but you will hear about that, too... :)

all best,
tench
 
Back
Top