Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 09-29-2011, 03:33 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 654,898
Hall of Famer is on a distinguished road
Default

Well you cannot send an array or object directly into mysql database, but there is a way to do the trick. Lets assume you have an array as below, the script will be able to perform magic for you:

PHP Code:
$idarray = array(1,2,3,4,5);
$idstring implode(","$idarray);
mysql_query("UPDATE table {$prefix}.adoptables SET idstring = '{$idstring}' WHERE id = '$id'"); 
This way your id array will be stored as a string in the table prefix.adoptables, column idstring, the implode function converts an array into a string.

To retrieve this data from your mysql table, use the explode function:
PHP Code:
$result mysql_query("SELECT * from table {$prefix}.adoptables WHERE id = '$id'");
$row mysql_fetch_array($result);
$idarray explode(","$row['idstring']); 
Its also possible to generate a random number from the id array, I will explain to you later after I return from dinner.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hall of Famer's PHP Tutorials: Chapter 6 - PHP Arrays Hall of Famer Tutorials and Tips 0 03-16-2013 07:14 PM
My MySQL? Rozel Questions and Supports 6 05-01-2011 08:53 AM
Mysql help? rickasawr Questions and Supports 5 04-26-2011 09:31 AM
MySQL: What to do? Knyfe Questions and Supports 18 03-11-2011 12:52 PM
mySQL help aroymart Questions and Supports 4 04-20-2009 12:13 AM


All times are GMT -5. The time now is 04:25 AM.

Currently Active Users: 1670 (0 members and 1670 guests)
Threads: 4,081, Posts: 32,032, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636