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
Link management script with multiple field input?
Old 08-23-2004, 03:11 AM Link management script with multiple field input?
Junior Talker

Posts: 1
Trades: 0
I run a fanfiction recommendation website and am in the process of a complete overhaul. Instead of manually updating the links everytime I read a new story and recommend it, I am thinking of using a link management script to help organise that. I have been searching for a suitable script for a while, but you see, the problem is that I need a multiple field input for my links.

The principle of my idea runs along scripts that work in PHP with mySQL database storage. The majority of scripts I have come across seem to focus entirely too much on allowing users to add their own links. I don't want any of that fancy gist, just a simple, multi field input database info sorted in categories.

Okay, say I want to add a rec, the information I want to input are -

- Story title (this would contain the direct link to said story)
- Author
- Pairing
- Webpage (this would be a link to the author's website or archive place)

Now this is where the problem is, on scripts I have come across, they usually only have 3 input fields. The name of the link, a description and the acutal url link. While I guess I can compromise and place the author and pairing info within the description field, it does not allow me to say, search via author or pairing or such. Not to mention the html output would be messy.

I'm really stuck on this and unless I find a suitable script (because I just don't have the knowledge to modify or write one), I cannot start revamping the entire site. So if you guys have any pointers or have come across scripts that may fit my scenario, please let me know. Thanks. =)
Asuki is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-23-2004, 05:59 AM Hey
Phobz's Avatar
Novice Talker

Posts: 8
Trades: 0
Hi m8
I seen this code on codewalkers.com, very useful.

<?
session_start();

$default_sort = 'story_id';
$allowed_order = array ('story_id', 'author');

if (!isset ($_GET['order']) ||
!in_array ($_GET['order'], $allowed_order)) {
$order = $default_sort;
} else {
$order = $_GET['order'];
}

$_SESSION['order'] = $order;

// This will be the sorting part, you make a link index.php?order=author.


/* connect to db */
mysql_connect ('localhost','user','pass');
mysql_select_db ('test');

// Set these to your settings.


/* construct and run query */
$query = "SELECT * FROM sometable ORDER BY $_SESSION['order']";
$result = mysql_query ($query);

/* make sure data was retrieved */
$numrows = mysql_num_rows($result);
if ($numrows == 0) {
echo "No data to display!";
exit;
}

/* now grab the first row and start the table */
$row = mysql_fetch_assoc ($result);
echo "<TABLE border=1>\n";
echo "<TR>\n";
foreach ($row as $heading=>$column) {
/* check if the heading is in our allowed_order
* array. If it is, hyperlink it so that we can
* order by this column */
echo "<TD><b>";
if (in_array ($heading, $allowed_order)) {
echo "<a href=\"{$_SERVER['PHP_SELF']}?order=$heading\">$heading</a>";
} else {
echo $heading;
}
echo "</b></TD>\n";
}
echo "</TR>\n";

/* reset the $result set back to the first row and
* display the data */
mysql_data_seek ($result, 0);
while ($row = mysql_fetch_assoc ($result)) {
echo "<TR>\n";
foreach ($row as $column) {
echo "<TD>$column</TD>\n";
}
echo "</TR>\n";
}
echo "</TABLE>\n";
?>

You will just need to go into your mysql db and add a column named story_id as (INT) with auto_increment for numbers.

Add which fields you want inside the array.

If you want to see this tutorial so it make more sense. Go to www.codewalkers.com > tutorials > database.

Sorting data tutorial.



Hope this helps m8.

Ill pm ya l8r to help you with inserting data into database and adding new fields if you want. Just give me a pm m8


Cya
Paul

Last edited by Phobz; 08-23-2004 at 06:08 AM..
Phobz is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Link management script with multiple field input?
 

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