3 Replies - 3992 Views - Last Post: 29 October 2011 - 01:15 AM Rate Topic: -----

#1 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

showing and checking data's

Posted 27 October 2011 - 09:47 PM

I'm not sure if this is the right section but since i'm more on php i posted it here


I'm trying to make a Account history record that shows the record of a "user/patient"
and i got no clue or complete idea to start it

its like this

if the user has no records on my
user_records tbl.

and he or she clicks the link of "my account history record"
it will show a content text " You have no record/s as of now , click this link to avail one of our services and have a appointment"

but if he or she got a record
a table or list of records such as avail'd service/s , price , paid , balance , blah..blah..
will show up

well at first my idea was to start first a admin page
to be able to input the record for a certain user/patient and set his or her bills and availd service/s

but got no complete or precise idea about how to start it...

any advices or any help that can be given to me?
or codes or etc...


any help would be appreciated...

p.s

i already have a login/register and a redirect link where it goes
after logging in.. for admins and for normal users...
separate pages so it means i got a own page for users and for admins..

This post has been edited by Syfer: 27 October 2011 - 09:49 PM


Is This A Good Question/Topic? 0
  • +

Replies To: showing and checking data's

#2 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: showing and checking data's

Posted 28 October 2011 - 08:05 AM

Why don't you approach it in this sort of method.

user table

id
name
address
email
---------------
records table

recordsID
userID
summary
visitDate

This way you have a one to many relation where one user can have more than one record in his/her history.

So when you look up a user, you'll obtain the user ID and make a search like this:

$result = mysql_query("SELECT * FROM records WHERE userID='$123'");



With PHP you'll make a check if there are records or not like so:


$num_results = mysql_num_rows($result); //gets how many rows
if ($num_results > 0){ //checks if rows > 0
  while($row = mysql_fetch_array($result)) //loops through all the rows if exist
    {
    echo '<h1>' . $row['name'] . '</h1>';
    echo '<br />';
    echo $row['summary'];
    echo '<hr />';
  }
} else {
    echo 'No records found.';
}



This way if you have multiple records which is a very likely possibility, especially in your scenario.

Please keep in mind this is only a basic outline of how it should be and how you can go about it. You need to plan properly of what you want to include in your tables and what kind of information you want to store and display.

Please feel free to ask anything about the code, btw it's not tested so I apologies if anything does not run properly (Hopefully not :P)

Hope his helps.
Was This Post Helpful? 2
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10783
  • View blog
  • Posts: 40,159
  • Joined: 27-December 08

Re: showing and checking data's

Posted 28 October 2011 - 09:39 AM

Prepared Statements are really a better option than the near deprecated mysql_*() family of functions. But I agree with sas1ni69- this is a database question. When you go to iterate through your results, if you find you have none, then just output no results present. Otherwise, build the appropriate output structure.
Was This Post Helpful? 1
  • +
  • -

#4 Syfer  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 190
  • Joined: 08-October 10

Re: showing and checking data's

Posted 29 October 2011 - 01:15 AM

Thanks for the suggestion/advice and so on , now i got a idea and clue how to start it ^_^

i appreciate your help :) thankss


CHEERS !

This post has been edited by JackOfAllTrades: 29 October 2011 - 05:00 AM
Reason for edit:: Removed unnecessary quotes

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1