Melançon Enterprises

Information about the Programming Language PHP

Working with Strings, especially HTML text

nl2br (as in new line to break converts newline characters (

Working with Databases

Apparently, you can use the function LIST() to assign every record of a row to a list of $variable_names in the order that your SELECT statement asked for them.  A small example using a WHILE loop:

$query2 = "SELECT jcode, designation from listing WHERE listing.fk_department = '$id'";
$result2 = mysql_db_query($database, $query2, $connection) or die ("Error in query: $query2. " . mysql_error());
echo "

";

A monster example:

$query = "SELECT listing.designation, listing.jcode, department.department, location.location, salary.salary, listing.responsibilities, listing.qualifications, listing.cname, listing.cmail, listing.posted FROM department, listing, location, salary WHERE department.id = listing.fk_department AND location.id = listing.fk_location AND salary.id = listing.fk_salary AND listing.jcode = '$jcode'";
$result = mysql_db_query($database, $query, $connection) or die ("Error in query: $query. " . mysql_error());
[ . . . ]
list($designation, $jcode, $department, $location, $salary, $description, $qualification, $cname, $cmail, $posted) = mysql_fetch_row($result);

Something to do when reading from the same result set more than once:

// resultset pointer back to zero
mysql_data_seek($result, 0);

empty(), is_numeric(), is_string -- more or less self-explanatory useful functions.

It seems that after you insert into something that has an autoincrement primary key field, which you do not mention at all in INSERT INTO database_name(field1, field2, field3) VALUES ('$value1', '$value2', '$value3'), you can get the unique identifier with this query: $id = mysql_insert_id($connection);.

All stolen from icarus of Melonfire.com who posted the Perfect Job tutorial at Devshed.com.

© 1998-2002 Melançon Enterprises   |   E-mail: webmaster@melanconent.com
URL: http://www.melanconent.com/info/computers/programming/php/