Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-18-2009, 03:13 PM Module system
Average Talker

Posts: 16
Trades: 0
Hey everyone, I am trying to make a system that displays certain modules in certain content boxes (based on the pageid.) I have a good idea on what to do but I need help on one thing. I have a table that has a field called |idrow|. In this row it has the order I want the modules to display... like 1324576. Those are each individual modules. How do I take this id and break it down to 1 number at a time. Basically, module one calls the first digit (1) and displays it, then module 2 takes the second digit (3) and calls that module.

I hope that made sense... it is a little confusing. Just ask for clarification if you need it. Thanks! .
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-18-2009, 03:58 PM Re: Module system
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Could you provide a code snippet where you're trying to do this?
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 07-18-2009, 04:09 PM Re: Module system
Average Talker

Posts: 16
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
Could you provide a code snippet where you're trying to do this?
I haven't started yet. The code will begin by pulling the valueid from the database and decoding it to send to a function that puts it in the content box. I just don't know how to make the script read that code one number at a time.

Last edited by Ghost Sniper X; 07-18-2009 at 04:11 PM..
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
Old 07-19-2009, 01:09 PM Re: Module system
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
You could pass the variables like ...&mod1=displaybox3&mod2=displaybox1 and so on?

This way it gets the variable for the module you want(in this case "displaybox3" for "mod1", the first module placement) to display "in order" of appearance on the page.

Otherwise, create different scenarios for layouts and have a code for each scenario?

Just a couple suggestions.
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 07-20-2009, 07:14 PM Re: Module system
Average Talker

Posts: 16
Trades: 0
Quote:
Originally Posted by racer x View Post
You could pass the variables like ...&mod1=displaybox3&mod2=displaybox1 and so on?

This way it gets the variable for the module you want(in this case "displaybox3" for "mod1", the first module placement) to display "in order" of appearance on the page.

Otherwise, create different scenarios for layouts and have a code for each scenario?

Just a couple suggestions.
Yeah, I thought about that. It would be really messy though, and harder to control.

Anyone know how to read a code like 24234 one number at a time? That is what is holding me back right now.
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
Old 07-20-2009, 07:34 PM Re: Module system
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
PHP Code:
<?php
$my_number 
12345;

for(
$i=0;$i<strlen($my_number);$i++) {
  echo 
$my_number[$i];
}
?>
This is using the character string access described at http://us.php.net/manual/en/language....string.substr
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 07-20-2009, 11:55 PM Re: Module system
Average Talker

Posts: 16
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
PHP Code:
<?php
$my_number 
12345;

for(
$i=0;$i<strlen($my_number);$i++) {
  echo 
$my_number[$i];
}
?>
This is using the character string access described at http://us.php.net/manual/en/language....string.substr
I understand how this works... however the for loop isn't displaying anything when I test it. When I test the string access it works fine.

Also, how does the code you supplied differ from just the basic code described in the link above? Would this help me keep the code more basic and less cluttered?

Thanks, this is a lot of help!
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
Old 07-21-2009, 12:02 AM Re: Module system
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
My bad, used a string function on a number...

PHP Code:
<?php
$my_number 
= (string)12345;

for(
$i=0;$i<strlen($my_number);$i++) {
  echo 
$my_number[$i];
}
?>
The basic code that I sent gives you the documentation for accessing single characters of a string. The code I posted, shows this for getting each character 1-by-1.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 07-26-2009, 05:37 PM Re: Module system
Average Talker

Posts: 16
Trades: 0
Hey, I have created a function that pulls a key from the database, then explodes it.

Now that I can control the id's, what would you recommend I do now? My main problem now is where to store the modules. Should the code all be in one file, or have them in separate files? I kind of want to store all the modules into one file, but how would I call the module using the number id?
Ghost Sniper X is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Module system
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30107 seconds with 12 queries