UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
September
Su M Tu W Th F Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Sponsored Links
Latest Postings
The History Thread...
by Gremelin
09/18/14 09:42 AM
Doom 3
by Cyrez
09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666
08/22/14 09:21 AM
Latest Reviews
Page 1 of 2 1 2 >
Topic Options
Rate This Topic
#19340 - 02/28/04 09:46 AM confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
Ok, i have the following table:

Quote:
confessed.php?section=4
It'll take and list a random item of the "type" sction... I guess you'd probably need to see it to see what I'm tryin to do, so you can check out http://confess.undergroundnews.com/ I'm mainly making this script out of sheer boredom and trying to check how things work...
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
Sponsored Links
      
#19341 - 02/28/04 12:46 PM Re: confessed.php?section=4 to display tabledata for section
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
Damn it!!!


Gizmo PLEASE fix this fucking no HTML tag crap in the code tags. I posted exactly what you wanted, but UBB would not post it besace I had > and <'s in the code.


Code:
//php intro tage here
//the rand function in php see http://www.php.net/manual/en/function.rand.php
$random = rand(1, $highest_id_number_in_the_database);
$dg = mysql_query("Select * from ugn_confession WHERE id = '$random'");
While($dg2 = mysql_fetch_array($dg)){
echo "".$dg2['type'].""; 
/* to add more info just 
echo "any text you want to add ".$dg2['db_feild_name']."";
*/
}
_________________________
My New site OpenEyes

Top
#19342 - 02/28/04 10:36 PM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
Code:
<html></html><?php ?>
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19343 - 02/28/04 10:36 PM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
works just fine for me... be sure you enclose the tags within [code][/code]
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19344 - 02/28/04 10:43 PM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
Code:
<?php
//the rand function in php see http://www.php.net/manual/en/function.rand.php
 $random = rand(1, $highest_id_number_in_the_database);
 $dg = mysql_query("Select * from ugn_confession WHERE id = '$random'");
   While($dg2 = mysql_fetch_array($dg)){
   echo "".$dg2['type'].""; 
   /* to add more info just 
   echo "any text you want to add ".$dg2['db_feild_name']."";
   */
}
?>
Looks all fine and dandy, but I don't see anything in there to take and do section=4...

See, all the differant types are 1-8, I'd want section= to take and load a type, but a random sin of said type...
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19345 - 02/28/04 10:48 PM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
http://confess.undergroundnews.com/confessed.php?section=4

All it loads is a blank page... The EXACT code I'm using on confessed.php is (slightly differant than sintax):

Code:
<?php require "connect.php"; ?>
<?php
$mysql_access = mysql_connect($host, $user, $pw) or die(mysql_error());
mysql_select_db($db) or die(mysql_error()); // make sure you add this ;)
?>

<?php
//the rand function in php see http://www.php.net/manual/en/function.rand.php
 $random = rand(1, $highest_id_number_in_the_database);
 $dg = mysql_query("Select *, DATE_FORMAT(date, '%H:%i on %d/%c/%Y') AS date2 from ugn_confession WHERE id = '$random'");
   While($dg2 = mysql_fetch_array($dg)){
   echo "".$dg2['type']."
";
   echo "".$dg2['date']."
";
   echo "".$dg2['id']."
";
   echo "".$dg2['name']."
";
   echo "".$dg2['confession']."
";
   /* to add more info just 
   echo "any text you want to add ".$dg2['db_feild_name']."";
   */
}
?>
See, what I'm goin for here is a little differant than what you think. See, there are 7 types of sin's, with 8 as miscelanious. Think of it as choosing a section. I want it so that people can basically do ?section=[number of the sin type] and it'll take and list a random sin that's in the database FOR that sin type...
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19346 - 02/29/04 06:55 PM Re: confessed.php?section=4 to display tabledata for section
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
well that is a horse of a different color.

Code:
//**************************************************************
<?
//*  referinf URL  below                                       *            
//*  http://confess.undergroundnews.com/confess.php?section=#  *
//**************************************************************
//This code is assuming that type is your section
//number in the table at the top of this thread
//(post).

$dg = ("Select * FROM ugn_confession WHERE type = '$section'");
$num_rows = mysql_num_rows($dg);
$count = "1"; 

while($dg2 = mysql_fetch_array($dg)){
   if($count == "1"){
      $random1 = "".$dg2['id']."";
   }else{
   }
$count = $count++
   if ($count == "$num_rows"){
      $random2 = "".$dg2['id']."";
   }else{
   }
}
?>
Then just use my code above again... Hmmmm this would only work if all section info was stored in sequential order.... In other words

Code:
 
Your_table
field1         feild2            type         id
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bla            bla               1            1
bla            bla               1            2
bla            bla               2            3
bla            bla               2            4
bla            bla               2            5
bla            bla               3            6


//
//The above would work  but this would not
//

field1         feild2            type         id
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bla            bla               1            1
bla            bla               3            2
bla            bla               2            3
bla            bla               5            4
bla            bla               6            5
bla            bla               1            6
 
My advise is store each section in a different table to allow you to index the data easier. Some thing like this in the code.


Code:
 
if($section == "1"){
//query such and such table
}else if($section == "2"){
//query bla bla table
}else if($section == "3"){
//query this and that table
}
 
That would be easier than using one table.
_________________________
My New site OpenEyes

Top
#19347 - 02/29/04 11:54 PM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
mmmk
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19348 - 03/02/04 02:44 AM Re: confessed.php?section=4 to display tabledata for section
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
See post above
_________________________
My New site OpenEyes

Top
#19349 - 03/02/04 02:58 AM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
Very interesting... I may go your route, I wanted to do it with the smallest set of tables possible, but I guess that isn't too possible :/... Ah well, it'll only take a few seconds to refine what I need...

One question, if I use them with each type having it's own query, what would the query be to echo the data to the page with only one row but have it randomize for each time it's posted...
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19350 - 03/02/04 04:53 AM Re: confessed.php?section=4 to display tabledata for section
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
Dude you can use the same code form the while function on. Like so..


Code:
<?
//*********************Start code for section 1*********************
if($section == "1"){
   $random_number = rand(1,$highest_id_number_in_this_table);
      $dg = mysql_query(SELECT * FROM ugn_confession1 WHERE id = '$random_number');
//*********************Start code for section 3*********************
}else if($section == "3"){
   $random_number = rand(1,$highest_id_number_in_this_table);
       $dg = mysql_query(SELECT * FROM ugn_confession2 WHERE id = '$random_number');
}
//after all the if statements you just do one while statement
While($dg2 = mysql_fetch_array($dg)){
   echo "".$dg2['type']."
";   
   echo "".$dg2['date']."
";   
   echo "".$dg2['id']."
";   
   echo "".$dg2['name']."
";   
   echo "".$dg2['confession']."
";
}
See the only thing that is different is you have to handle the rand(); function and mysql_query in the if, else statements. The rest is the same because the variable $dg is passed to while just the same. The reason is only one $dg = mysql_query(); function will be processed. Make sense?

Also your table need to be constructed identicaly for this to work of course.


Now you could do it in one table IF.....

Section 1 is id numbers 1 - 500
Section 2 is id numbers 501 - 1000
Section 3 is id numbers 1001 - 1500

and so on


This would be difficult to update dynamicaly though. But if you did this this way the first script I posted today would work. But the id's have to be sequential to do the random functions I coded. Of course, maybe you could put it into an array... hmmmmmm

**note This may cause it to be slower for some reason. I have used arrays a bit lately and found they seem to slow things down a bit. But that is on my 2 servers
Solaris OS running apache and Redhat9 Running apache

Code:
$dg = ("SELECT * FROM you_table WHERE id = '$section'");
$count = "0"
$number_rows = mysql_num_rows($dg);
WHILE($dg mysql_fetch_array($dg)){
$ugn_array = $dg2;
}

$random_num = (0, $number_rows);
echo "".$ugn_array['$random_num']['type']."
";
and so on...
that should work for you....
_________________________
My New site OpenEyes

Top
#19351 - 03/02/04 11:06 AM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
'eh I'll screw with it in the morning
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19352 - 03/02/04 10:45 PM Re: confessed.php?section=4 to display tabledata for section
§intå× Offline


*****

Registered: 12/03/02
Posts: 3255
Loc: Maryland
Well it is now 17:43 local to me and Shhhh....


/me listens to crikets......

*churp churp churp*


Did it work, Which way did you go? Questions?
_________________________
My New site OpenEyes

Top
#19353 - 03/02/04 10:49 PM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
Well, I'm GOING to go with the seperate databases, but I'm tryin to think of the best route to go with the entering of info heh...
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
#19354 - 03/03/04 12:01 AM Re: confessed.php?section=4 to display tabledata for section
Gremelin Offline

Community Owner
*****

Registered: 02/28/02
Posts: 7193
Loc: Portland, OR; USA
Damnit, now I'm confused about how to go about inputting the data! lol...

Ok, see input page above, how would I go about making my page input into the differant databases, I know I'd use if/else statements, but i'm not entirely sure how to go about it...

see: http://crap.undergroundnews.com/confess.zip for source.
_________________________
Donate to UGN Security here.
UGN Security, Back of the Web, Elite Web Gamers & VNC Web Design Owner

Top
Page 1 of 2 1 2 >

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 03/02/02
Posts: 136
Forum Stats
2148 Members
46 Forums
34501 Topics
69671 Posts

Max Online: 1567 @ 04/25/10 02:20 AM
Top Posters
UGN Security 27663
Gremelin 7193
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Tim050, Gecko666, defghi795767, Devo60, ali
2148 Registered Users
Who's Online
1 registered (Cyrez), 359 Guests and 315 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!