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
is there a better way to do this? to view this?
Old 02-12-2008, 12:56 AM is there a better way to do this? to view this?
Extreme Talker

Posts: 176
Name: Aaric
Trades: 0
I am just learning php/mysql. So far I learned to create a form that updates a database. I am now learning to make a page that displays the database records.

This is what I have now: http://www.bjjnews.org/TUF/fighterdb/formatting.php

You can see, it is just too much info and is ugly. How do you think I could set this up? Will someone help?
aaricwon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-12-2008, 02:14 AM Re: is there a better way to do this? to view this?
Skilled Talker

Posts: 71
Trades: 0
Instead of having all of the info on one page, have just a few columns of important info (like maybe their name, email, and status...or whatever) and then have each piece of text clickable, which will take you do a more detailed page. This way you can list the detailed data for just one record, not all at once.

To make this work effectively you'll want to make sure you have an ID in your table, like a userid or just a tableid.

You can do this by just making your text a link, something like:
<a href="formatting.php?id='.$row['user_id'].'">'.$row['first_name'].'</a>
(Note: that code will vary depending on how your database and query/code is setup)

Now that it is a link, you can delete the other columns that you don't want, just keep the ones that are most important and need to stick out.

Then, to make the page for the details...
(Note...this is just a basic example)
Code:
<?php

if (isset ($_GET['id'])) {
    $id = $_GET['id'];
    if (is_numeric ($id)) { // make sure the ID in the URL is a number
         $sql = mysql_query ("SELECT * FROM yourtable WHERE userid='".$id."'");
         $num = mysql_num_rows ($sql);
         if ($num > 0) { // check to make sure the record exists
              $row = mysql_fetch_array ($sql);

              echo '<table border="1" style="border: 1px solid thin #000000;">
                <tr>
                  <td>First Name:</td>
                  <td>'.$row['first_name'].'</td>
                </tr>
                <tr>
                  <td>Last Name</td>
                  <td>'.$row['last_name'].'</td>
                </tr>
              </table>';

              // That's just an example of two fields, I'm not typing them all out

         } else {
             echo 'This ID does not exist!';
         }
    } else {
        echo 'ERROR: ID is not a number!';
    }
} else {
    // PUT THE REST OF YOUR CODE HERE

}

?>
That should get you started.

I didn't test that, but it should work.
CrazeDizzleD is offline
Reply With Quote
View Public Profile
 
Old 02-12-2008, 02:18 AM Re: is there a better way to do this? to view this?
RadGH's Avatar
Skilled Talker

Posts: 76
Name: Radley
Trades: 0
I find listing items by their title in a simple drop down list and having a small table to display the contents pretty effective.
RadGH is offline
Reply With Quote
View Public Profile
 
Old 02-12-2008, 10:40 AM Re: is there a better way to do this? to view this?
Extreme Talker

Posts: 176
Name: Aaric
Trades: 0
oops I accidentally posted twice

Last edited by aaricwon; 02-12-2008 at 12:14 PM.. Reason: sorry... double post... accident
aaricwon is offline
Reply With Quote
View Public Profile
 
Old 02-12-2008, 12:14 PM Re: is there a better way to do this? to view this?
Extreme Talker

Posts: 176
Name: Aaric
Trades: 0
THANKS! w/your help I was able to figure it out.

Thanks for teaching me something new!
aaricwon is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to is there a better way to do this? to view this?
 

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