Current location: Hot Scripts Forums » Programming Languages » PHP » Support database


Support database

Reply
  #1 (permalink)  
Old 05-05-04, 05:50 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Support database

I will try to keep this post short and to the point.

A freind of mine has started up in PC repair.

I sugested when he was out and needed some info he could go to his website and look at a database.

He WAS happy with this before but now :He wants his customers to have some access to the information.

Before I just had a database with one table and a form to search the datbase.

Question is what to do now - I do not want to input all the data into two different tables.

Choices : Two tables and when the data is uploaded only a certain amount goes into one. One table and add a variable so only a certain amout of the data can be seen.

Any sugestions either on a way to do this or a link to a code would be helpful.

Anthony
Reply With Quote
  #2 (permalink)  
Old 05-05-04, 06:24 AM
the_mole001's Avatar
the_mole001 the_mole001 is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Australia
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Hey,

It might not be the best way, but i'd suggest you add a column to the table for something like "access" and have a number/word system. Say a user can onli have a low access have low, then medium or high, or 1, 2 and 3. Then when printing results catorgrize what you want each level to see. Just an idea

-Peter
__________________
Current Project: GGAC Website
Project Link: http://peter.5gigs.com/
Reply With Quote
  #3 (permalink)  
Old 05-05-04, 08:24 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
I had not thought this through.

All I need is two different query's :

Select col1, col2 FROM database - for user

Select * FROM database - for Admin

Use a "login" for Admin which would let him have the " * " search.

Thanks for making me think Peter.

Anthony
Reply With Quote
  #4 (permalink)  
Old 05-06-04, 09:20 AM
cbunting cbunting is offline
Newbie Coder
 
Join Date: Dec 2003
Location: Delaware
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Hello,
You are correct. You don't need any additional tables. Just put togeather another script or page and only pull out the info that you want the users to see.

If you run into any problems, Let me know and i'll do what I can to help.

Regards,
Chris
Reply With Quote
  #5 (permalink)  
Old 05-06-04, 03:29 PM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the offer Chris; I am trying to be clever and its not working !

PHP Code:

// Query by make


  
$query "SELECT DISTINCT make FROM support ORDER BY make";
  
$result mysql_query($query) or die ("Couldn't execute query.");

  echo 
"<form action = ",$PHP_SELF," method='post_self'><select name='make'>\n";

  while (
$row mysql_fetch_array($result))
  {
    
extract($row);
    echo 
"<option value='$make'>$make\n";
  }
  echo 
"</select>\n";
  echo 
"<input type='submit' value='Select by make'></form>\n";
        
if (isset(
$make)) {print "no";}

else {print 
"yes";} 
I thought I would try and be clever :

Instead of the user inputting something to search for I thought I would give them a list of the options - other wise the could take ages finding an answer.

I then thought instead of passing the variable to another page I would save pages by sending to itself.

The first form works OK and the dropdown list is populated OK; when I select an option that is added to the URL e.g. ?make=dell

From there it goes wrong as the "isset" check I put in always comes up "no".

Can someone help me out please Anthony
Reply With Quote
  #6 (permalink)  
Old 05-07-04, 01:40 AM
nd2 nd2 is offline
Wannabe Coder
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
try empty() instead of isset() i also spoted this line
echo "<option value='$make'>$make\n";

you may want to make it like

echo "<option value='".$make."'>".$make."</option>\n";

or even

echo '<option value="'.$make.'">".$make."</option>';
__________________
IonCMS (Coming Soon.)
http://ioncms.com
--
Ncaster (Free php/mysql cms)
http://ncaster.cjb.net
Reply With Quote
  #7 (permalink)  
Old 05-07-04, 03:48 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the ideas nd2 but my code looks about right echo "<option value='$make'>$make\n"; if I change it to echo "<option value='".$make."'>".$make."</option>\n"; all my options in the list are $make !
This was my first attempt at php and I will check it again later - Have to go soon wifie is on about geting some DIY done. I have a feeling the problem may be here though.

The empty bit did not work properly either so I tried both :
PHP Code:

if (empty($make)) {print "empty = no";}

else {print 
$make;}

if (isset(
$make)) {print "<br>isset = no";}
else {print 
$make;} 
When first navigating to page :

Hewlet packard
isset = no

When sellecting Compac and pressing submit ( with ?make=Compac in the address bar )

Hewlet packard
isset = no

Note: Hewlet packard is the last option on my list.

Anthony
Reply With Quote
  #8 (permalink)  
Old 05-07-04, 05:31 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
I don't know why people depend on registered globals!!

try this one intstead:
PHP Code:

if (isset($_GET['make']))

  echo 
$_GET['make'].': Yes';
else
  echo 
'no'
also I noticed that your form method is 'post_self' not POST !!
what is this post_self anyway ?
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #9 (permalink)  
Old 05-07-04, 06:29 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
WAHOO that works now ; thanks NeverMind. All I have to do i intigrate it into my next form.

I was desperate last night and was trying anything hence " what is this post_self anyway ? " I thought I had seen it somewhere : )

If I leave the method on the form will not work - dose nothing not even add the make to the URL.

I now have - the isset still a test.

PHP Code:

echo "<form action = ",$PHP_SELF,"><select name='make'>\n";


  while (
$row mysql_fetch_array($result))
  {
    
extract($row);
    echo 
"<option value='$make'>$make\n";
   }
echo 
"</select>\n";
echo 
"<input type='submit' value='Select by make'></form>\n";

if (isset(
$_GET['make']))
  echo 
$_GET['make'].': Yes';
else
  echo 
'no' 
This adds the make to the URL OK and output of the "isset" is Dell: Yes

Thanks for the help guy's

Anthony
Reply With Quote
  #10 (permalink)  
Old 05-07-04, 06:59 AM
Bonzo's Avatar
Bonzo Bonzo is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 340
Thanks: 0
Thanked 0 Times in 0 Posts
I think you were trying to catch me out NeverMind and it worked !!

PHP Code:

if (isset($_GET['make'])) 

  echo 
$_GET['make'].': Yes'
else 
  echo 
'no' // where is the ; 
Anthony
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
Share database over the Internet nitinkedia The Lounge 2 11-20-03 02:07 PM
Share database over the internet nitinkedia PHP 0 07-11-03 12:22 AM
Share database over the Internet nitinkedia New Members & Introductions 1 07-10-03 02:50 PM


All times are GMT -5. The time now is 10:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.