Jump to content

pass variables from PHP mysql form to PHP mysql select/ while On same page.


Recommended Posts

I can't seem to understand how to do this.

Can someone help?

 

I created a form to select members and hit submit.

Then I wan to ON SAME PAGE display the selected members information.

 

{CODE}

 

//This works

echo "Select Player - ";
echo "<select name='players'>";
    while ($row = $result->fetch_assoc()) {
        unset($playersid, $name);
        $playersid = $row['playersid'];
        $name = $row['name'];
        echo '<option value="'.$playersid.'">'.$playersid.' - '.$name.'</option>';
    }
echo "$playersid";
echo "</select>";
echo '<font color="White"><input type="submit" value="Submit">';

// End works

 

// THIS IS WHERE I AM STUCK
$name = $_POST['name'];
$playersid = $_POST['playersid'];
// VARIABLES NOT PASSED

 

//THIS IS DISPLAYED
echo '<h3 class="pos_right">Weekly Report for $name</h3>';

echo '<p class="pos_right">
    <table border="1">
    <thead>
        <tr>
            <td align="center" width="75">Week<br>Played</td>
            <td align="center" width="75">Did They <br>Attend</td>
            <td align="center" width="75">Points</td>
            <td align="center" width="75">Amount<br>Paid</td>
            <td align="center" width="75">High<br>Hand</td>
            <td align="center" width="50">Fifty<br>Fifty</td>
        <tr>
    </thead>';

// SELECT PLAYER  INFO FROM DATABASE

//NOT WORKING, HERE. WORKS WELL IN MYSQL SQL

$query = mysqli_query($conn,"SELECT b.week, a.attend, a.points, a.payout, a.hh, a.ff
FROM data a, dates b, players c
WHERE a.playersid = c.playersid
AND a.dateid = b.dateid
AND a.playersid = 12");
    
$res = mysqli_query( $conn, $query ) or exit( mysqli_error($conn) );

 

// NOTHING DISPLAYED
     while($row = mysqli_fetch_array($query)) {
    echo "<tr>
            <td>" . $row['week'] . "</td>
            <td>" . $row['attend'] . "</td>
            <td>" . $row['points'] . "</td>
            <td>$" . $row['payout'] . "</td>
            <td>$" . $row['hh'] . "</td>
            <td>$" . $row['ff'] . "</td>

    </tr>";

    }
    echo "</table>";

 

{END CODE}

 

This is the last script I need help with, all other 5 scripts wor well.

 

Thanks for your help.

you need to have php's error_reporting set to E_ALL and display_errors set to ON in the php.ini on your development system, so that php will help you by reporting and displaying all the errors that it detects. you will save a TON of time. edit - lol, which you were already told you needed to do in your last thread.

 

for your first problem, you will be getting undefined array index errors, since the name of your <select > form field is - 'players'

 

you should also be using a method='get' form since the form is determining what will be gotten/displayed on the page.

 

for your second problem, you have a variable name mismatch, between what you are storing the result from the query in and what you are using in your loop, that php would also be giving you errors for.

 

p.s. - the forum's bbcode tags are - 


and can be applied by selecting the code and hitting the <> menu button.

Edited by mac_gyver

i hope you mean your web host. your isp wouldn't have anything to do with web hosting. you also should be learning and developing php code on a local development system, not an a live server at a web host.

 

those two settings may be set somewhere to those two values, but hey are not in effect. in both of your threads you would have been getting php errors that would help you find the problems, but you are not getting the errors or they are being hidden somehow.

I had someone from my web host send me an example of a php.ini file which he advised me where to locate it and it works. Thanks.

I would like to use a lock development host system, but for the life of me I can't understand how to setup ECLIPSE or MySQL/Apache/PHP on OS X Yosemite.

Either i am too dumb or the instructions are not meant for first timers.

 

If you know of a web site that offers instructions for either of these for beginners, I'll be very grateful.

 

I'm learning a lot from this forum, keep up the good work.

 

Thanks

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.