didgydont Posted December 7, 2007 Share Posted December 7, 2007 hi all im trying to learn php ive been using www.w3schools.com to make my self a client data base but now im trying to make a button to submit a $result the code i tried is this echo "<table border='2'> <tr> <th>id #</th> <th>Client Name</th> </tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Uid'] . "</td>"; echo "<td>" . $row['FirstName'] ." ". $row['LastName'] . "</td>"; echo "<td>" <form action="idsearch.php" method="post"> <input type=". $row['Uid'] ." name="Uid" /> <br /> <input type="submit" VALUE="Show Details" /> </form> "</tr>"; } echo "</table>";mysql_close($con); ?> thank you for your time also does anyone know of any other good sites for learning php Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2007 Share Posted December 7, 2007 There is a good link in my signiture. I'm sorry (don't mean to be meen), but that code is pretty far off the track. I'm not even sure of exactly what your trying to do. Quote Link to comment Share on other sites More sharing options...
didgydont Posted December 7, 2007 Author Share Posted December 7, 2007 thank you for your reply it must have been realy bad if you couldnt understand i started trying to learn about 4 days ago. the code bellow is what ive done so fare and it works great but rather than have to enter the Uid in a form at the bottom of the page i was trying to make a button beside the user that automaticly grabbed the Uid and when pressed would send it to idsearch.php i love php so far just some things have banging my head against the wall i will have a look at those links in the mean time thank you again .. <html> <?php $con = mysql_connect("localhost","database_name","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("database_name", $con); $result = mysql_query("SELECT * FROM clients ORDER BY FirstName"); echo "<table border='2'> <tr> <th>id #</th> <th>Client Name</th> </tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Uid'] . "</td>"; echo "<td>" . $row['FirstName'] ." ". $row['LastName'] . "</td>"; "</tr>"; } echo "</table>";mysql_close($con); ?> <form action="idsearch.php" method="post"> ID#: <input type="text" name="Uid" /> <br /> <input type="submit" VALUE="Show Details" /> </form> <br /><br /> </html> Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted December 7, 2007 Share Posted December 7, 2007 In your idsearch.php page, get the number from the input box for your id and do the query e.g. <?php // this value will come from text box named Uid $id = $_POST['Uid']; echo $id; // you can query the table and search from the id $query = mysql_query("SELECT * FROM table WHERE id=$id"); // and display just like you did above... ?> Quote Link to comment Share on other sites More sharing options...
didgydont Posted December 7, 2007 Author Share Posted December 7, 2007 i already have that in idsearch.php what i was trying to do was remove the form from the bottom of the page and replace it with a show details button that would send the uid to my idsearch.php thank you for your imput i think im gonna go crazy still fun though <html> <?php $con = mysql_connect("localhost","database_name","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("database_name", $con); $result = mysql_query("SELECT * FROM clients WHERE Uid='$_POST[uid]'"); while($row = mysql_fetch_array($result)) { echo "<b>Name:</b>" . " " . $row['FirstName'] ." ". $row['LastName']; echo "<br />"; if (empty ($row['Address'])) {echo "<b>Address:</b> None.";} else {echo "<b>Address:</b>" . " " . $row['Address'];} echo "<br />"; if (empty ($row['Mobile'])) {echo "<b>Mobile Number:</b> None.";} else {echo "<b>Mobile Number:</b>" . " " . $row['Mobile'];} echo "<br />"; if (empty ($row['Land'])) {echo "<b>Land Line:</b> None.";} else {echo "<b>Land Line:</b>" . " " . $row['Land'];} echo "<br />"; if (empty ($row['Email'])) {echo "<b>Email:</b> None.";} else {echo "<b>Email:</b>" . " " . $row['Email'];} echo "<br />"; echo "<br />"; echo "<br />"; echo "<br />"; }mysql_close($con); ?> <br /><br /> </html> Quote Link to comment Share on other sites More sharing options...
PHP_PhREEEk Posted December 7, 2007 Share Posted December 7, 2007 i think im gonna go crazy still fun though weEeeEEeEeEEE !! heheh I remember my first beer! Hey, welcome to PHP Freaks! PhREEEk Quote Link to comment Share on other sites More sharing options...
didgydont Posted December 9, 2007 Author Share Posted December 9, 2007 thanx PHP_PhREEEk but i think i have a long way to go before i become a PhREEEk.. ill get there one day Quote Link to comment Share on other sites More sharing options...
didgydont Posted December 17, 2007 Author Share Posted December 17, 2007 just an update this solved my problem the show details button made my table look funny but it works echo "<table border='2'> <tr> <th>id #</th> <th>Client Name</th> <th>Client details</th> </tr>";while($row = mysql_fetch_array($result)) { $uid = $row['Uid']; echo "<tr>"; echo "<td>" . $row['Uid'] . "</td>"; echo "<td>" . $row['FirstName'] ." ". $row['LastName'] . "</td>"; echo "<td>"; echo "<form action=\"idsearch.php\" method=\"post\">"; echo "<input type=\"hidden\" name=\"Uid\" value=\"$uid\" /> <br />"; echo "<input type=\"submit\" VALUE=\"Show Details\" />" ; echo "</form>"; echo "</td>"; "</tr>"; } echo "</table>";mysql_close($con); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.