Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage
Php > Database Related sample source codes
Mimic ASPs GetString functionality
Mimic ASPs GetString functionality require("conn.php"); //require connection data $delimiter_string = "</td>\n\t\t
"; //the \n\t\t pattern is added to be able to format the source clearly $sql = "select * from kids"; $result = conn($sql); //custom connection function - so don't phreak out $data = GetString($result, $delimiter_string); //call the function echo "
$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>
" would get you element1 </td>
element2 </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
\n\t\t
".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 ?>
Privacy Policy
|
Link to Us
|
Links