Download presentation
Presentation is loading. Please wait.
1
PHP/MySQL Tricks & Techniques
11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
2
Charles Kaplan - Maximum Computer Systems, Inc.
Introduction Charles Kaplan Maximum Computer Systems, Inc. Sr. Sales Executive Sales and Support of IBM i Solutions for 30+ years with IBM, Barsa Consulting, and Maximum Computer Systems Past President, Treasurer Long Island System Users Group (iSeries) Lecture Series – PHP & MySQL for RPG Programmers Certifications IBM Power – i Sales Specialist IBM Power – i Technical Support IBM Power – AIX & LINUX Sales Specialist Vision Solutions – MIMIX Sales Questions x119, office , cell 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
3
Charles Kaplan - Maximum Computer Systems, Inc.
Agenda HTML Maps Keyword Search Opening up New Tab/Windows with Hyper Links Image Re-Sizing List Filtering – Populating Dropdowns with MySQL Queries File Upload Restrictive WebPage Access without Login’s Blocking users from webpages Alphabetic Navigation Bar 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
4
Charles Kaplan - Maximum Computer Systems, Inc.
HTML Maps Display an image <img src=“image.jpg” alt=‘Image Description’> Hyperlink <a href=“pgm.php” alt=‘Link Description’> object </a> Hyperlink Image <a href=“pgm.php”><img src=“image.jpg”></a> 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
5
Charles Kaplan - Maximum Computer Systems, Inc.
HTML Maps <img src=“mapfilename.jpg” usemap=“mapname” ismap alt=“map description”> <map name=“mapname”> <area shape=“poly” coords=“1,1,1,10,10,10,10,1” href=“program.php?id=ny” alt=“New York”> <area shape=“rect” coords=“1,10,10,10,20,10,20,1” href=“program.php?id=nj” alt=“New Jersey”> </map> 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
6
Charles Kaplan - Maximum Computer Systems, Inc.
HTML Maps Q: How do I find a map image? A: Google Images Q: How do I find map coordinates? A: View Page Source Q: How do I determine my own map coordinates? A: MS-PAINT 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
7
Keyword or Full Text Search
Search a text field for keywords Define a FULLTEXT index off of target field, (table type must be MyISAM) SELECT fields FROM table WHERE MATCH(ft_index_field) AGAINST(‘keywords’ in BOOLEAN MODE) Prefixes: “+” (AND), “-” (NOT), none (OR) Suffix: “*” (WILDCARD) Quoted Words: “word1 word2” – phrase 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
8
Opening Up New Tabs/Windows with Hyper Links
Open Link in New Window <a href=“URL” target=“_blank”> object </a> Good practice to open new window when linking to another website, otherwise users will be leaving your website 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
9
Charles Kaplan - Maximum Computer Systems, Inc.
Image Resizing <img src=“imagefilename” width=“xxx” height=“yyy” alt=“description> Browsers will stretch/shrink image into defined space distorting the image $size = GETIMAGESIZE(imagefilename) $width = $size[0] $height = $size[1] 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
10
Charles Kaplan - Maximum Computer Systems, Inc.
Image Resizing Code $max_width = 240; $max_height = 240; $pix = “image.jpg”; $size = getimagesize($pix); $new_width = $size[0]; $new_height = $size[1]; $ratio = $new_width / $new_height; if ($new_width > $max_width) { $new_width = $max_width; $new_height = round($new_width/$ratio); } if ($new_height > $max_height) { $new_height = $max_height; $new_width = round($new_height * $ratio); } echo “<img src=‘$pix’ width=‘$new_width’ height=‘$new_height’>”; 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
11
List Filtering - Populating Dropdowns w/MySQL Queries
MYSQL Query SELECT DISTINCT city FROM casinos WHERE (state=‘ca’) and (type=‘Card Room’) ORDER BY city 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
12
List Filtering - Populating Dropdowns w/MySQL Queries – PHP Code
$query = “SELECT DISTINCT city FROM casinos WHERE state=‘ca’ ORDER BY city”; $result = mysql_query($query); if ($result) { echo “<select name=‘city’>\n”; while(list($city) = mysql_fetch_row($result)) echo “<option>$city</option>\n”; echo “</select>”; } 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
13
Charles Kaplan - Maximum Computer Systems, Inc.
File Uploads 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
14
Blocking Access to a WebPage
Browsers provide “environmental” information each time they make a request, including the requesting TCP/IP address. If you can determine TCP/IP addresses of “unwanted” users (PING) you can block them. $_SERVER[‘REMOTE_ADDR’] 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
15
Blocking Access to a WebPage PHP Code Example
$remote_addr = $_SERVER[‘REMOTE_ADDR’]; switch ($remote_addr) { case “ ”: /* example */ case “ ”: /* local users */ case “ : $ban = 1; break; /* aol.com */ default: $ban = 0; } if ($ban) echo “You may not enter this website”; else { show webpage; } 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
16
Alphabetic Navigation Bar
Within a webpage, a good feature is to be able to provide links within the page. This helpful for long and/or complicated pages. An example would be a table of contents at the top of the page that users can click on to go directly to the desired section. 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
17
Alphabetic Navigation Bar PHP Code Example
$query3 = "SELECT DISTINCT substring(casinoname, 1, 1) FROM casino WHERE " . $where . " ORDER BY casinoname"; $result3 = mysql_query($query3); $i = mysql_numrows($result3); $width = 20 * (1 + $i); echo "<table width='$width' align='center' border='1‘ rules='all‘ frame='border' bgcolor='silver‘> <tr> <td width='20' align='center'><a href='#0'>#</a></td>\n"; while (list($letter) = mysql_fetch_row($result3)) { $letter = strtoupper(substr($letter,0,1)); echo "<td width='20' align='center'> <a ref='#$letter'>$letter </a> </td>\n“; } echo "</tr></table><br>\n"; 11/22/2018 Charles Kaplan - Maximum Computer Systems, Inc.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.