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-26-2010, 05:48 PM PHP echo a SQL table
kcmartz's Avatar
Super Talker

Latest Blog Post:
~Gri to Kcmartz~
Posts: 120
Name: Kenson
Location: Washington, USA
Trades: 0
In the forum software I use, SMF, there is a links directory mod, and I am trying to ask the author but to no avail. I want to have PHP echo out a random link/discription from the SQL table "smf_links" and display it in a block on the bottom of the left side blocks on http://www.kcmartz.com/

How do I do this? Thanks
__________________
Thanks,

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
for problems/site.
kcmartz is offline
Reply With Quote
View Public Profile Visit kcmartz's homepage!
 
 
Register now for full access!
Old 07-26-2010, 06:15 PM Re: PHP echo a SQL table
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
I suppose you could select * from thetable;
Then count the rows returned,

Now use php to choose a random number between 1 and the max row number.

Then do a select for that row with that ID number.

Then echo the details you need into wherever on your page.
__________________

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

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


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 07-26-2010, 06:23 PM Re: PHP echo a SQL table
kcmartz's Avatar
Super Talker

Latest Blog Post:
~Gri to Kcmartz~
Posts: 120
Name: Kenson
Location: Washington, USA
Trades: 0
I am a complete sucker, and suck at php. I only know echo (text and html) and include for including a file NO OTHER PHP, not even syntax for other codes.
__________________
Thanks,

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
for problems/site.
kcmartz is offline
Reply With Quote
View Public Profile Visit kcmartz's homepage!
 
Old 07-26-2010, 06:25 PM Re: PHP echo a SQL table
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Ok cool, We have all been there.

Check this out, Read it, Play around with it.
It will REALLY help more than someone just giving you code.


http://www.tizag.com/mysqlTutorial/
__________________

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

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


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 07-26-2010, 06:33 PM Re: PHP echo a SQL table
kcmartz's Avatar
Super Talker

Latest Blog Post:
~Gri to Kcmartz~
Posts: 120
Name: Kenson
Location: Washington, USA
Trades: 0
Ok, i will tomorrow I am starting to be busy now. google bookmarked
__________________
Thanks,

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
for problems/site.
kcmartz is offline
Reply With Quote
View Public Profile Visit kcmartz's homepage!
 
Old 07-29-2010, 03:40 PM Re: PHP echo a SQL table
Junior Talker

Posts: 1
Name: max pain
Trades: 0
you can create a class in php similar to echo, but in this case will output the table
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
keysrecover is offline
Reply With Quote
View Public Profile
 
Old 07-29-2010, 04:17 PM Re: PHP echo a SQL table
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by keysrecover View Post
you can create a class in php similar to echo, but in this case will output the table
You must not have read this part:
Quote:
Originally Posted by kcmartz View Post
I am a complete sucker, and suck at php. I only know echo (text and html) and include for including a file NO OTHER PHP, not even syntax for other codes.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-29-2010, 07:41 PM Re: PHP echo a SQL table
ModDish's Avatar
Super Talker

Posts: 116
Trades: 0
you could do it easily with a txt file and php

one value per line ( if the 79th line gets selected, anything on that line will be echoed )

then use the follow code to select a random line and echo it

<?
$textfile ="random.txt";
$items = file("$textfile");
$item = rand(0, sizeof($items)-1);
echo $items[$item];

?>

so put each url and descriptions on a separate line

so say line 79 was

ModDish - Website Design firm - http://www.moddish.com - blahhhhhhhhhh < description ( like my plug lol)


it would echo it on the doc with the above code.

you could also format each line with <b> </b> ( or any html code) around the title etc , and the html code would work when its echoed.
__________________
Thanks
Evan
From ModDish -
Please login or register to view this content. Registration is FREE

Last edited by ModDish; 07-29-2010 at 07:50 PM..
ModDish is offline
Reply With Quote
View Public Profile
 
Old 08-02-2010, 08:52 AM Re: PHP echo a SQL table
Banned

Posts: 4
Name: bradwatson
Trades: 0
foreach ($resultSet as $row)
{
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['result'] . "</td>";
echo "</tr>";
}
with:

foreach ($resultSet as $row)
{
echo "Dear ".$row['name'].", you are ".$row['result'];
}
bradwatson is offline
Reply With Quote
View Public Profile Visit bradwatson's homepage!
 
Reply     « Reply to PHP echo a SQL table
 

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