|
|
|
|
|
|
| |
ASP(VBScript), from time to time, has some neat features. One is a function called GetString, which pertains to the Recordset object. Its purpose is to pull the entire recordset into a formatted string and close the connection to free resources. This type of functionality can be quite useful in a high load environment. So I thought it would duplicate the functionality with PHP. So here it is...
| <?php
require("conn.php"); //require connection data
$delimiter_string = "</td>\n\t\t<td>"; //the \n\t\t pattern is
added to be able to format the source clearly
$sql = "select * from tableName";
$result = conn($sql); //custom connection
function - so don't freak out
$data = GetString($result, $delimiter_string); //call the function
echo "<table>$data</table>"; //print out the results
function GetString($handle,$delimiter)
{
/*
This function emulates the ASP GetStrings function. It creates an
array of the dataset where the the array is a string with a certain delimiter
ie if you were to pass a delimiter of "|" your data would be
element1 | element2 | element3
for a pipe-delimited string to pass around
delimiter of "</td><td>" would get you
element1 </td><td> element2 </td><td> element3
to make it really easy to create a table dump of your data
(Note: I added \n\t\t in the pattern to be able to see the output neatly formatted when I view the source code for it)
*/
if (mysql_num_rows($handle)>0){
//initialize the array
$RsString = ''; //array();
//loop thru the recordset
while ($rows = mysql_fetch_array($handle,MYSQL_ASSOC))
{
//add some additional tags to open and close the table rows with some formattting
$RsString .=
"\n\t<tr>\n\t\t<td>".implode($delimiter,$rows)."</td>\n\t</tr>\n";
} //wend
return $RsString;
}else{
//no records in recordset so return false
return false;
} //end if
//close the connection
mysql_close($handle);
} //end function
?> | | |
|
| mysql_escape_string Categories : PHP, MySQL, Databases, Strings | | | Phorum, MySQL, Language, UK date format, MySQL UK Date format Categories : PHP, Date Time, Strings, MySQL, Databases | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | phpAds, a complete banner and ad management system with detailled tracking and stats. Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | color codes for positive and negative numbers Categories : PHP, MySQL, Databases, HTML | | | Authorize Me! An authentication script. Categories : MySQL, Databases, Authentication, PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | This script is a contact form between users of a
website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps | |
|
|
|