On Tue, 2006-03-21 at 04:45 +0000, Mark Mckee wrote:
> hi all
> 
> I am definately stuck now. i have managed to insert data into my
> table 
> using php and sql staements.
> 
> I have also managed to display that data on a single page.
> 
> the points where i am stuck
> 
> 1) how do i display all the data contained in the table and not just
> the 
>   one row?
> 

To answer this question, here's an excerpt from my current project:

if ($fullname == "Choir")
   $result = mysql_query("SELECT entry_name FROM ChoirEntry WHERE
school_id='$schoolid' ORDER BY entry_name ASC;") or die("Could not find
record.");
else
   $result = mysql_query("SELECT entry_name FROM BandEntry WHERE
school_id='$schoolid' ORDER BY entry_name ASC;") or die("Could not find
record.");


if (mysql_num_rows($result) > 0)
{
   while($a_row = mysql_fetch_array($result, MYSQL_ASSOC))
   {
      foreach($a_row as $field)
      {
         print "<tr><td align='center'>$field</td></tr>\n";
      }
   }
}
else
{
   print "<tr><td align='center'>None Entered Yet</td></tr>";
}


As you can see, I use a while loop to iterate through the results using
mysql_fetch_array.

> 2) i have my input form up and ready. a place for the header, test and
> a 
> drop down box containing the 40 pages i want to choose from to
> update. 
> how do i send the correct header text and the chioce in the drop down
> to 
>   the correct table?

<form method='post' action='nextpage.php'>
<select name='choices'>
<option>Option1</option>
<option>Option2></option>
<input type='submit' value='Send Choice">

On nextpage.php have a line near the top of the script that says:
$someVar = $_POST['choices'];
> 
> i think thats it for now lol. any help would be grately appreciated
> 
> kind regards
> 
> Mark...
> 
> 
> 
> 
> Mark Mckee wrote:
> > thank you for the help.
> > 
> > i wil keep trying to get it working.
> > 
> > Michael Sullivan wrote:
> > 
> >>On Tue, 2006-03-21 at 00:52 +0000, Mark Mckee wrote:
> >>
> >>
> >>>hi all
> >>>
> >>>i want to create an inut page for the content on my website. is it 
> >>>possible to have 1 data entry box and choose the specific what
> table
> >>>of 
> >>>a database to put it usign a drop down box?
> >>>
> >>>if so, can someone please point me in the right direction. i have
> >>>been 
> >>>troubling over this for the last few days
> >>>
> >>>thanks in adavce
> >>>
> >>>mark m...
> >>
> >>
> >>I don't see why this wouldn't be possible.  You would just use the
> table
> >>name selected from the list box in constructing the query string you
> use
> >>in your mysql_query.
> >>
> >>Ex.
> >>
> >>I select 'SomeTable' from a list box called 'list' and hit the
> Submit
> >>button.  Another page is called, in which is a line like this:
> >>
> >>$list = $_POST['list'];
> >>
> >>
> >>
> >>You code says:
> >>
> >>$query = "SELECT * FROM ".$list;
> >>
> >>Then you issue 
> >>
> >>$result = mysql_query($query, $link2DB) or die ("Could not access
> table
> >>$list:".mysql_error());
> >>
> >>or whatever you want... 
> >>
> >>
> >>
> >>
> >>
> >>Community email addresses:
> >>  Post message: php-list@yahoogroups.com
> >>  Subscribe:    [EMAIL PROTECTED]
> >>  Unsubscribe:  [EMAIL PROTECTED]
> >>  List owner:   [EMAIL PROTECTED]
> >>
> >>Shortcut URL to this page:
> >>  http://groups.yahoo.com/group/php-list 
> >>Yahoo! Groups Links
> >>
> >>
> >>
> >> 
> >>
> >>
> >>
> >>
> > 
> > 
> > 
> > Community email addresses:
> >   Post message: php-list@yahoogroups.com
> >   Subscribe:    [EMAIL PROTECTED]
> >   Unsubscribe:  [EMAIL PROTECTED]
> >   List owner:   [EMAIL PROTECTED]
> > 
> > Shortcut URL to this page:
> >   http://groups.yahoo.com/group/php-list 
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> > 
> 
> 
> Community email addresses:
>   Post message: php-list@yahoogroups.com
>   Subscribe:    [EMAIL PROTECTED]
>   Unsubscribe:  [EMAIL PROTECTED]
>   List owner:   [EMAIL PROTECTED]
> 
> Shortcut URL to this page:
>   http://groups.yahoo.com/group/php-list 
> 
> 
> 
> SPONSORED LINKS 
> Php mysql 
> Job postings 
> 
> 
> ______________________________________________________________________
> YAHOO! GROUPS LINKS
> 
>      1.  Visit your group "php-list" on the web.
>           
>      2.  To unsubscribe from this group, send an email to:
>          [EMAIL PROTECTED]
>           
>      3.  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>         Service.
> 
> 
> ______________________________________________________________________
> 



Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to