PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 20th, 2005, 07:33 AM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 116 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 49 sec
Reputation Power: 5
unknown error..

hi guys,

i am trying to write a code that can actually get a value from one table and then use that value to run another SQL query,,, hmm.. i dun really know how to explain but i hope u guys can help..

can u guys help me to check why when i use something like $info.$i, it doesn't have any value inside ? did i miss something here ? did i insert the variables wrongly ? can you guys let me know how i suppose to write in order to get the value i want .. i actually want it to loop for 10 times since i have 10 records for a user in page_info table.

this is the code that i wrote :

Code:
<?
// connect to db
include "../include/global.php";

// navigation menu
$query2 = mysql_query("SELECT * FROM `sorting` where `site_name` = '$site_name'") or die("Error occured");
$row2 = mysql_fetch_array($query2);

for( $i = 1; $i < 11 ; $i++)
{
$info.$i = mysql_query("SELECT * FROM page_info where `site_name` = '$site_name' AND id = '{$row2['sort$i']}'") or die("Error occured");

$display.$i = mysql_fetch_array($info.$i);
//echo "$info.$i";
//echo "|| $display.$i";
}

echo $display1['name'];
echo $display2['name'];
..
.

?> 



there is no output displayed and i received an error saying Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource.

please advise.. thanks.

Reply With Quote
  #2  
Old January 20th, 2005, 07:48 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
$info.$i is likely to cause an error

Perhaps you should make it an array...
Simply use:
$info[] = mysql_query(whatever)

I don't quite understand what your second query is accomplishing... all the results would be the same, no?
$site_name isn't changing anywhere.

And are you always going to loop 10 times?

Reply With Quote
  #3  
Old January 20th, 2005, 08:56 AM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 116 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 49 sec
Reputation Power: 5
yes,, i definitely need to loop 10 times..

actually in the first query, i want to get the information of which page to be displayed first,, then in the second query, i want to display the page name according to the results obtained from the first query (sort the id : ascending)..

i am very weak in array,, do u mind to explain a little bit more how to use the array in my case ??

really appreciate for giving me advicess.. thanks..

Reply With Quote
  #4  
Old January 20th, 2005, 12:27 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Can you give us a little more info on your table structure and perhaps some sample data?

Maybe then we'll fully understand your question and therefore be able to suggest a more efficient way of doing this...

Maybe present a modified code, if you tried using the array already...

Reply With Quote
  #5  
Old January 30th, 2005, 11:32 PM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 116 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 27 m 49 sec
Reputation Power: 5
Hi guys,

it is still not working..

my sorting table structure :
Code:

CREATE TABLE `sorting` (
  `username` varchar(20) NOT NULL default '',
  `site_name` varchar(20) NOT NULL default '',
  `sort1` char(5) NOT NULL default '',
  `sort2` char(5) NOT NULL default '',
  `sort3` char(5) NOT NULL default '',
  `sort4` char(5) NOT NULL default '',
  `sort5` char(5) NOT NULL default '',
  `sort6` char(5) NOT NULL default '',
  `sort7` char(5) NOT NULL default '',
  `sort8` char(5) NOT NULL default '',
  `sort9` char(5) NOT NULL default '',
  `sort10` char(5) NOT NULL default ''
) TYPE=MyISAM;



my page_info table structure :
Code:
CREATE TABLE `page_info` (
  `username` varchar(20) NOT NULL default '',
  `site_name` varchar(20) NOT NULL default '',
  `id` int(2) NOT NULL default '0',
  `page_name` varchar(50) NOT NULL default '',
  `file_name` varchar(50) NOT NULL default '',
  `status` varchar(10) NOT NULL default ''
) TYPE=MyISAM;


what i wan to do is something like what most website creator application can do for the page sorting.. i am thinking to do something like that too.. so i thought the flow can be like this :

// fetch the record from 'sorting' table to get the page arrangement information

for ur information, sort(x) in sorting table is used to store page id
// after that, i will use for loop to get the information of the page, like page name, file name and etc based on the sort(x) value : page id info..


I have tried many ways but it is not working.. it will be great if you guys can advise what method i can use to accomplish this.. or let me know what i have done wrong in my coding..

thanks..

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > unknown error..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway