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
loading 1 <object> file out of 369
Old 03-24-2005, 08:18 AM loading 1 <object> file out of 369
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
I'm looking for a way to put 369 <object>'s in one file and to load the selected one using something like "http://www.adress.nl/something.php?id=3383" (where I can change the 3383 to another one so the page shows another object.


this way I don't need 369 html files for all files and this way I don't have to edit all files to give all of them the same background.
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
 
Register now for full access!
Old 03-24-2005, 09:01 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
The only way I can think of is to have one monster if/else or switch statement.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 09:21 AM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
I asked this on another forum as well and this is what I got.

PHP Code:
<?php 
if($id == 1001) {
?>
//show object no 1001
<?php 
} else if($id == 1002) {
?>
//show object no 1002
<?php 
} else if($id == 1003) {
?>

and so on.....
now, I understand this and I know how to expand this, but where do I put the object code?

<object> example:

Code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="640" height="460">
 <param name="movie" value="10key_speed.swf">
 <param name="quality" value="high">
 <embed src="10key_speed.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="640" height="460"></embed>
</object>

Last edited by hermanos182; 03-24-2005 at 09:28 AM..
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-24-2005, 09:34 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Replace where it says...

//show object no ####

with your object code for that number.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 09:43 AM
Unknown.

Posts: 1,693
Trades: 0
How about storing all the info in a database.. would save having all the else and if statments..

If you created a table named objectfiles with the following fields..

id
src
height
width

Then to call that file in php use the filename.php?id=23 so then it loads the file which is listed in the record of the row with the id 23.

The PHP code to use..

PHP Code:
<?

//Connect to database first!


$query "SELECT * FROM objectfiles WHERE id = '$id'";
$result mysql_query($query);
$numrows mysql_num_rows($result);

if(
$numrows 1) {
echo 
"No such file";
exit;
}
else {
$row mysql_fetch_array($result);

?>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="<?=$row[width]?>" height="<?=$row[height]?>">
 <param name="movie" value="<?=$row[src]?>">
 <param name="quality" value="high">
 <embed src="<?=$row[src]?>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"width=" <?=$row[width]?>" height="<?=$row[height]?>"></embed>
</object>


<?
}
?>
I havent had chance to test it.. so hopefully it should work
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 09:48 AM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
AHA, I knew there was some method I was missing. I guess I just feel like doing things the hard way as of late.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 10:00 AM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
trying it out, if I don't know something or w/e I'll just edit this post :P

edit:

ok I just noticed I suck at tables :s

maybe a detailed explanation for what you suggested? cuz I don't see where I fill in the height, width, src & id?

I'm using phpmyadmin btw

Last edited by hermanos182; 03-24-2005 at 10:39 AM..
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-24-2005, 10:39 AM
Unknown.

Posts: 1,693
Trades: 0
To create the table in phpMyAdmin

If you goto SQL then enter the following query..

Code:
CREATE TABLE `objectfiles` (
`id` SMALLINT( 4 ) NOT NULL ,
`src` VARCHAR( 200 ) NOT NULL ,
`height` SMALLINT( 4 ) NOT NULL ,
`width` SMALLINT( 4 ) NOT NULL
);
That will create the table for you.
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 10:44 AM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
created the table
put the php code in a .php file

and then?

I'm a noob huh?
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-24-2005, 11:37 AM
Unknown.

Posts: 1,693
Trades: 0
If you havent already you need to add the database connection...

So if you havent...

In the PHP file where it says '//Connect to database first! ' replace it with..

PHP Code:
$location 'localhost'// 99.9% chance you dont need to change

//Change to your database connection details..

$database 'DATABASE_NAME';
$username 'DATABASE_USER';
$password 'DATABASE_PASS';

$conn mysql_connect("$location","$username","$password");
if (!
$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database"); 
..and make sure to change the database name, username and password.

Then you just need to add all the information into the database you can do this through phpMyAdmin if you select the objectfiles table then select insert..

id = the id you want for the file.
src = the link to the file. eg. 10key_speed.swf
height = height!
width = width!

Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 12:29 PM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
Parse error: parse error, unexpected '=' in /home/sites/webhosting/blink182/blink182/www/test.php on line 3

that's in this line:

location = 'localhost';


I checked my settings and my location = localhost so I don't know where I got this message from.

if it can't be something else should I just contact my host?
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-24-2005, 12:34 PM
Unknown.

Posts: 1,693
Trades: 0
Umm.. it looks like youve missed the $ sign off the start..

it should be..

$location = 'localhost';
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-24-2005, 01:06 PM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
sweet ^_^ that works

you guys rock

tnx a lot


EDIT: someone told me that it's possible to only have 1 database and to load all the <object> codes with that database?

if that's with all the else's and if's could someone explain that to me and maybe add a piece of code?

Last edited by hermanos182; 03-24-2005 at 05:14 PM..
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-24-2005, 06:09 PM
Unknown.

Posts: 1,693
Trades: 0
Quote:
Originally Posted by hermanos182
someone told me that it's possible to only have 1 database and to load all the <object> codes with that database?

if that's with all the else's and if's could someone explain that to me and maybe add a piece of code?
Thats basically the same thing that you are doing with this code.

The else's and if's are just an longer method.. I cant think how it would be done using them though.. in programing less equals best If you can achieve the same with using less code it will run faster and also save you precious bandwidth
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-25-2005, 03:05 AM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0


yeah, that's true, but now I have to make 369 databases....

I just wanna try some stuff out to see what works best for me cuz I don't see myself making 369 databases ><

Last edited by hermanos182; 03-25-2005 at 03:50 AM..
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-25-2005, 07:28 AM
Unknown.

Posts: 1,693
Trades: 0
You dont need to make 369 databases

Just the one table and enter the 369 records into it...

and at the end of the day its gonna be as hard as typing 369 else and if statements out
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-25-2005, 12:13 PM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
if I have a table with the 4 fields as described, with a max of 4 chars / field (in 3 of them) how can I put all the 369 records in one table?
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Old 03-25-2005, 12:17 PM
Unknown.

Posts: 1,693
Trades: 0
Each of the four fields creates one row in the table...

so you just insert another row of data into that table..

thats how MySQL works
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-25-2005, 12:22 PM
hermanos182's Avatar
Experienced Talker

Posts: 39
Location: netherlands, ede
Trades: 0
ok I see, I just tested it and it works

you just made my day

/me jumps around the house


oh one more thing :P with embded and applet's it should work the same right?

edit2: I tried it out and embded files work but I can't get it to work with java applets

Last edited by hermanos182; 03-25-2005 at 05:22 PM..
hermanos182 is offline
Reply With Quote
View Public Profile Visit hermanos182's homepage!
 
Reply     « Reply to loading 1 <object> file out of 369
 

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 1.99455 seconds with 12 queries