Jump to content

Archived

This topic is now archived and is closed to further replies.

RSprinkel

A few things needing help on please.

Recommended Posts

Hi all,

I need some help here on a few things I am trying to do.

1) I am trying to create a form that I want data pulled out of a MySQL table called users from a column named sierra and then placed in a Drop Down box in the form.  I have searched here and tried many of the ideas here and apparently I am not grabbing the concept.

2) I want to have a form that pulls data from 3 different databases.  It is a profile form for my league.  When someone clicks on a members name the profile page will pull up displaying 3 different things.  1)Basic info on the member coming from the users table, Accomplishments within the league - Coming from the accomplishments table, and 3) Winnings - which would come from a win table.  All of these tables are in the same database. 

Thank you all very much in advance.

Share this post


Link to post
Share on other sites
Part 1

[code]Choose a user: <select name="user">
<?php
// assumes database connection already exists
$query = "SELECT sierra from users";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
while ($row = mysql_fetch_array($result)) {
    echo "<option value='". $row['sierra']. "'>". $row['sierra']. "</option>\n";
?>
</select>[/code]

Share this post


Link to post
Share on other sites
Hi AndyB,

I am getting this error now when I inserted this code.

Parse error: syntax error, unexpected $end in /home/../../../../test.php on line 75

Share this post


Link to post
Share on other sites
[code]Choose a user: <select name="user">
<?php
// assumes database connection already exists
$query = "SELECT sierra from users";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query);
while ($row = mysql_fetch_array($result)) {
    echo "<option value='". $row['sierra']. "'>". $row['sierra']. "</option>\n";
} // close the loop, dummy
?>
</select>[/code]

My code, my fault, see fixed version above.

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=108379.msg436037#msg436037 date=1158504691]
what line is 75 then sorry my cristal ball not working.
[/quote]

LOL sorry I didn't post that and when I re-read what I wrote I was about to post it.

But no need to now.  It WORKS GREAT thank you very much for the update.

Again Thanks.

Share this post


Link to post
Share on other sites
It's amazing how a little coffee reduces errors in my scripts :)

For future reference, that error message - and it probably references the line number after the end of your script - is symptomatic of an unclosed loop.

Share this post


Link to post
Share on other sites
cheek your spelling of the varable.

also cheek that the varable is set and also your POSTING['correct name '];

good luck.

Share this post


Link to post
Share on other sites
Ok I got this script working now without any errors.  Now when I go to post the info into the database it posts everything but the sierra name into the db.  Man this PHP stuff is tuff, LOL.

Here is the process script.

[code]<?php

include 'db.php';

$sierra = $_POST['sierra'];
$date = $_POST['date'];
$series = $_POST['series'];
$nmod = $_POST['nmod'];
$track = $_POST['track'];

$sierra = stripslashes($sierra);
$date = stripslashes($date);
$series = stripslashes($series);
$nmod = stripslashes($nmod);
$track = stripslashes($track);

//insert info into win table
$sql = mysql_query ("INSERT INTO win (sierra, date, series, nmod, track)
VALUES('$sierra','$date','$series','$nmod','$track')") or die (mysql_error());
if(!$sql){
echo 'There has been an error processing your pirep. Please contact the webmaster.';
}

mysql_close($connection);

//show user decision page
include 'test_filed.php';
?>[/code]

All table fields are correct in the db and coincide with the script.

Again Thanks much for tolerating me and my NON PHP knowledge, LOL.

Share this post


Link to post
Share on other sites
check the form to ensure that the name of the 'name' field in the input line is indeed sierra, spelling and case identical to the name of the variable you're expecting in the $_POST array.

Share this post


Link to post
Share on other sites
AndyB,

Thanks again very much for your expertise.  I did something dumb and changed the <select name="sierra"> to <select users="sierra">.  That is strictly my fault.  What a DUMB thing for me to do, LOL.

Again Thank You very much.  Working like a charm now.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.