- Consulting
- Depository and Moving Services
- Digital Solutions
- Education
- OCLC Services
- Resource Sharing
- eResources and Products
- Technology Sandbox
- Grants, Funding, Giving
Eventually we would like to have a database that is searchable for snippets and other bits of code that may help you constuct awesome web pages. In the meantime we will start with some bits from the Dynamic Web Design Class and go from there. If you have some that you would like to add, for now, send me the code in an email and I will post it.
1. Connecting PHP and mySQL
mysql_connect($host, $username, $password);
mysql_select_db($database, $connection);
2. Submitting Queries and Displaying Results
mysql_query($query, $connection);
mysql_num_rows($result);
mysql_fetch_array($result);
mysql_free_result($result);
3. Advanced Results Display
strpos($haystack, $needle);
You might also try:
str_replace($find, $replace, $string);
strtotime($time_string);
strip_tags($html_code);
4. Using Forms for Data Entry
$url = 'http://www.webmonkey.com/tutorial/Add_HTML_Forms_to_Your_Site';
echo "A quick guide to HTML forms if you need a refresher: " . $url;
mysql_query($query);
array($key1 => $value1, $key2 => $value2);
array_keys($array);
sizeof($array);
isset($variable);
is_numeric($variable);
header("Location: " . $url);
exit();
6. Validating Form Results, Advanced
session_start();
setcookie($cookie_name, $value, $expiration, $path, $domain, $secure);
session_id();
function custom_function_name($arguments) { /* code snippet */ }
array_key_exists($key, $array);
8. Advanced Concepts
strtotime($mysql_time_string);
time();
mktime($hours, $minutes, $seconds, $months, $days, $years);
date($format, $timestamp);
mail($to, $subject, $message, $headers);
stripslashes($escapedquotesinstring);
(code courtesy of Steve Spohn)