fmsguy06 Posted November 15, 2009 Share Posted November 15, 2009 Hello to all! I have made a database allowing others to enter information about themselves (create.php): <?php require_once("database.php"); if (isset($_POST['submit'])) { $firstname = mysql_real_escape_string( $_POST['firstname'] ); $lastname = mysql_real_escape_string( $_POST['lastname'] ); $bio = mysql_real_escape_string( $_POST['bio'] ); $gender = mysql_real_escape_string( $_POST['gender'] ); $sql = "INSERT INTO profiles VALUES(null, '".$firstname."','".$lastname."','".$bio."','".$gender."')"; $run = mysql_query($sql); if ($run) { echo "Your Project Was Created Successfully"; } else { echo "There was an error".mysql_error(); } } else { ?> <form action="create.php" method="post"> First Name:<input type="text" name="firstname" /><br /> Last Name:<input type="text" name="lastname" /><br /> BIO:<br /> <textarea name="bio" cols="50" rows="4"></textarea><br /> Female:<input type="radio" name="gender" value="female"> Male:<input type="radio" name="gender" value="male"><br /> <input type="submit" name="submit" value="Create Profile" /> </form> <?php } ?> which is stored in index.php: <?php //list out records in our table require_once('database.php'); $sql = "SELECT id, firstname, lastname FROM profiles"; $run = mysql_query($sql); echo "<table border=\"1\">"; echo "<tr>"; echo "<th>ID</th>"; echo "<th>First Name</th>"; echo "<th>Last Name</th>"; echo "<th>Actions</th>"; echo "</tr>"; while ($row = mysql_fetch_array($run)) { echo "Another "; echo "<tr>"; echo "<td>".$row['id']."</td>"; echo "<td>".$row['firstname']."</td>"; echo "<td>".$row['lastname']."</td>"; echo "<td>"; echo "<a href=\"view.php?id=".$row['id']."\">View |<a/>"; echo "<a href=\"edit.php?id=".$row['id']."\">Edit |<a/>"; echo "<a href=\"delete.php?id=".$row['id']."\">Delete<a/>"; echo "</td>"; echo "</tr>"; } echo "</table>"; ?> and here is the main databse.php: <?php $db_server = "localhost"; $db_name = "project"; $db_user = "root"; $db_password = ""; $dbc = mysql_connect( $db_server, $db_user, $db_password ) or die("Could not connect to Database. "); $dbs = mysql_select_db( $db_name ) or die("Could not select database. "); ?> I created an edit and delete of the index.php, which work fine. To view what is in the database, I'm not sure how to go about. I can see the firs and last name and ID in index, and delete it if need be, but in a view.php I'm trying to make it so that, first and last as well as gender and bio can be seen, of the selected, when view is selected in the index.php next to a name. Any advice? I thank you in advance! Link to comment https://forums.phpfreaks.com/topic/181660-viewing-a-particular-record-in-a-database/ Share on other sites More sharing options...
marklarah Posted November 15, 2009 Share Posted November 15, 2009 What? Link to comment https://forums.phpfreaks.com/topic/181660-viewing-a-particular-record-in-a-database/#findComment-958163 Share on other sites More sharing options...
fmsguy06 Posted November 16, 2009 Author Share Posted November 16, 2009 How I have the link to view.php next to every name in the database <?php // echo "<a href=\"view.php?id=".$row['id']."\">View |<a/>"; echo "<a href=\"edit.php?id=".$row['id']."\">Edit |<a/>"; echo "<a href=\"delete.php?id=".$row['id']."\">Delete<a/>"; // ?> Edit and delete work fine, but I am not sure what to place in view.php itself to allow all the information they entered to actually be seen. Link to comment https://forums.phpfreaks.com/topic/181660-viewing-a-particular-record-in-a-database/#findComment-958169 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.