TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-27-2007, 08:42 AM   #1 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default Millions of actions from one variable?

Okay... I was wondering about this... you have an item. The item costs a dollar. you make several hundred things displaying the item all over your site in different fashions. You change the price all over your site by editing the variable $price


you want to add another item, and plan to keep adding items and changing attributes regularly. what would be the easiest way? Arrays and foreach statements littered across the code? some kind of OOP thing (I have not the slightest clue how to use OOP?) This sounds like a gallery system...
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 12-27-2007, 01:29 PM   #2 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

You should dive into MySQL(i).. PHP: MySQL - Manual or PHP: mysqli - Manual and maybe some tutorials Google
sjaq is offline  
Reply With Quote
Old 12-27-2007, 04:56 PM   #3 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

I know you're trying to help, but saying "MySQL is the answer" doesn't help me. I was going to get into MySQL when I started to make the member system I wanted to make.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 12-27-2007, 05:27 PM   #4 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

A database is your best solution. If you dont want to use a database, arrays are your next best option.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-27-2007, 06:56 PM   #5 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

... HOW would I use a database? This is like throwing me out in the desert and saying "water is at an oasis". How would I use a database to update 20+ pages with a new block of code that has the information of the block of code?

like... TACO:
price: $3.00 USD
size: XL

and then 20 pages display that (in different fashions...)
but I want to duplicate the same way it was displayed on all those pages, INCLUDING giving it it's own new page if that needs to be done, just by adding

taco 2
price: free
size: XXL
taste: yummy.

I appreciate the help, but... It is just confusing me more.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 12-27-2007, 08:00 PM   #6 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

There are lots of tutorials on the web, I gave you a google search with loads of tutorials. It would be such a waste of time to write another one when there are loads of excellent ones on the web.

read this...
sjaq is offline  
Reply With Quote
Old 12-27-2007, 08:16 PM   #7 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

All I can say is that that doesn't help me at all. I know what MySQL is. I am asking HOW not WHAT.

Quote:
Originally Posted by sjaq View Post
You should dive into MySQL(i).. PHP: MySQL - Manual or PHP: mysqli - Manual and maybe some tutorials Google
Quote:
Originally Posted by Aaron View Post
I know you're trying to help, but saying "MySQL is the answer" doesn't help me. I was going to get into MySQL when I started to make the member system I wanted to make.
Quote:
Originally Posted by Village Idiot View Post
A database is your best solution. If you dont want to use a database, arrays are your next best option.
You basically said the same thing over and over after I said it didn't help.

Lets repeat this for the third time if you don't get it:

There is a code that makes a box on a page called "blue". The box has information in it. Hell, the box fetches information from a MySQL table. Now, there are a whole bunch of pages that do something and display the information in the SQL table.

How would I make it so the function does itself again if there are two tables of information?

(I really hope I don't sound like an asshole here, but this is driving me nuts.)
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 12-27-2007, 08:43 PM   #8 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

Ok, I'm sorry but it sounded like you didn't knew what MySQL was...

How do you mean "if there are to tables of information"? Or do you mean rows?
sjaq is offline  
Reply With Quote
Old 12-27-2007, 08:58 PM   #9 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

Well...
Each row stores a value, and each column stores a value for that value, right?

so table taco
price 2.45
size xl

and then table taco 2
price 3.56
sixe xxl


Well, there are probably more ways to do that O.o I haven't gotten too far into MySQL. You know what... I'm gonna go get something to eat...
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 12-27-2007, 09:11 PM   #10 (permalink)
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

So you really don't understand the use of MySQL if you don't know how to do that

But here's a basic script that does what I think you want to do..
First there is the database structure:

and the database content:


The script:
PHP Code:
<?php 

    $connection 
mysql_connect('localhost''root') or die('database connection failed: 'mysql_error());
                 @
mysql_select_db('testing'$connection);
    
    
$query mysql_query('SELECT * FROM test_row') or die(mysql_error());
    
    while(
$row mysql_fetch_object($query)) {
        print 
'<h2>'$row->name .'</h2>'"\n";
        print 
'<h3>price: $ '$row->price .'</h3>'"\n";
        print 
'<p>'$row->description .'</p>' "\n";
    }
    
    
mysql_free_result($query);
    
mysql_close($connection);

?>
Which produces:
HTML Code:
<h2>iPod nano</h2>
<h3>price: $ 400</h3>
<p>Some iPod description here</p>
<h2>MacBook Pro</h2>
<h3>price: $ 3000</h3>
<p>MacBook Pro description here</p>
<h2>Towel</h2>
<h3>price: $ 15</h3>
<p>This is a awesome towel! (it has dolphins on it!)</p>
Hope you see how to use MySQL now..
sjaq is offline  
Reply With Quote
Old 12-27-2007, 11:08 PM   #11 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Its like an excel spreadsheet.
__________________

Village Idiot is offline  
Reply With Quote
Old 12-27-2007, 11:23 PM   #12 (permalink)
The Contributor
 
Join Date: Apr 2005
Location: Kent, UK
Posts: 54
Thanks: 0
Dr John is on a distinguished road
Default

Aaron, I strongly suggest you get a big fat book on PHP and MySQL, AND a slim book on the same topic AND a slim one on database theory and design. Read the thin ones first, from cover to cover. Then start of the thick book (as the thin ones will only give you a few ideas to get started) and read as much of it as possible.

THEN, when you've tried a lot of the examples/exercises in these all books, attempt your project.

I'm not being funny, database theory is a big subject, and it's clear you need a lot more background knowledge to make progress. And that knowledge is locked up in textbooks, not in a few lines of a reply in a forum.
__________________
www.kidneydialysis.org.uk
Dr John is offline  
Reply With Quote
Old 12-29-2007, 06:03 AM   #13 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

I still need to lounge through PHP and MySQL for dummies third edition. And that is after PHP 5 for dummies. After that what books will you suggest? (I only get the dummies books because they are free.)
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:55 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design