Jump to content

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.

Link to comment
https://forums.phpfreaks.com/topic/21051-a-few-things-needing-help-on-please/
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]
[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.
[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.
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.

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.