naveenbj Posted January 22, 2008 Share Posted January 22, 2008 Hello , hOPE ANYONE CAN HELP ME FOR THIS.. <?php // Make a MySQL Connection mysql_connect("localhost", "root", "admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM form_info") or die(mysql_error()); echo "<table border='1'>"; echo "<tr><th>Id Nor:</th> <th>First Name:</th> <th>Last Name:</th> <th>Email:</th> <th>Birthday:</th> <th>Gender:</th> <th>Address:</th> <th>Phone</th> <th>Mobile</th> <th>Fax</th></tr>"; // store the record of the "form_info" table into $row while($row = mysql_fetch_array($result)){ // Print out the contents of the entry // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['id_nor']; echo "</td><td>"; echo $row['FirstName']; echo "</td><td>"; echo $row['LastName']; echo "</td><td>"; echo $row['Email']; echo "</td><td>"; echo $row['Birthday']; echo "</td><td>"; echo $row['Gender']; echo "</td><td>"; echo $row['Address']; echo "</td><td>"; echo $row['Phone']; echo "</td><td>"; echo $row['Mobile']; echo "</td><td>"; echo $row['Fax']; echo "</td></tr>"; } echo "</table>"; ?> ----------------- i DONT KNOW WHERE IM WRONG SO IF ANYONE CAN GET ME SM IDEA WOULD BE APPRICIATED!! rEGARDS, NJ Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/ Share on other sites More sharing options...
Dada78 Posted January 22, 2008 Share Posted January 22, 2008 What are you trying to do and what is your problem? Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445890 Share on other sites More sharing options...
dare87 Posted January 22, 2008 Share Posted January 22, 2008 TRY <?php $query = "SELECT firstname, lastname, email FROM form_info"; $results = @mysql_query($query); if ($results) { BLAH BLAH } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445891 Share on other sites More sharing options...
naveenbj Posted January 22, 2008 Author Share Posted January 22, 2008 Thanks for reply!! See i have a mysql table and i want to show the table data in browser window. So im able to see table data in browser window but i want that data in table so here i got problem Hope you get wht i mean... Regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445892 Share on other sites More sharing options...
naveenbj Posted January 22, 2008 Author Share Posted January 22, 2008 I got the issue.I was using two while loops so thats the reason .. Thanks for all to give me suggestion . If anyone can give me sm idea about how to place edit and delete features in this table.. Hope you all get wht i mean. ---------------- Regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445902 Share on other sites More sharing options...
mmarif4u Posted January 22, 2008 Share Posted January 22, 2008 echo "<a href='edit.php?$row[id_nor]'>Edit</a>"; Any row u can pick from ur table,Id is mostly effecaint . echo "<a href='delete.php?$row[id_nor]'>Delete</a>"; U can make edit.php and delete.php pages OR can make just one page and Pass there action like: echo "<a href='edit_delete.php?$row[id_nor]&action=delete'>Delete</a>"; echo "<a href='edit_delete.php?$row[id_nor]&action=edit'>Edit</a>"; Now just make one script edit_delete.php and Use GET to get the values from the 1st page. Hope it will help. Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445907 Share on other sites More sharing options...
naveenbj Posted January 22, 2008 Author Share Posted January 22, 2008 echo "<a href='edit.php?$row[id_nor]'>Edit</a>"; Any row u can pick from ur table,Id is mostly effecaint . echo "<a href='delete.php?$row[id_nor]'>Delete</a>"; U can make edit.php and delete.php pages OR can make just one page and Pass there action like: echo "<a href='edit_delete.php?$row[id_nor]&action=delete'>Delete</a>"; echo "<a href='edit_delete.php?$row[id_nor]&action=edit'>Edit</a>"; Now just make one script edit_delete.php and Use GET to get the values from the 1st page. Hope it will help. Hello mmarif4u, Thanks for reply!! That code is working but u wrote tht to make any edit page and use GET to get the values But im not able to do so if you can give me more idea on this would be gr8 to me:) Regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445920 Share on other sites More sharing options...
mmarif4u Posted January 22, 2008 Share Posted January 22, 2008 Sorry i forgot to add id in url. echo "<a href='edit.php?id=$row[id_nor]'>Edit</a>"; Lets take example. It will take every record with id and in the another page you can use GET to get the value. like: $id=trim($_GET['id']); And do the rest of coding using where clause in query like: $sql="select * from table where id='$id'"; Show the data or you can also amend it there. Just to make some further coding. Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445923 Share on other sites More sharing options...
dare87 Posted January 22, 2008 Share Posted January 22, 2008 DELETE - this is from my code you will have to change it. <?php // Include the PHP script that contains the session information. include('../includes/session_admin.php'); // Get the user id from the URL. $bid = $_GET['bid']; // Connect to the database. require_once ('../../../datemysql_connect.php'); // Set up the query. $query = "DELETE FROM listing WHERE b_id=$bid"; // Run the query. $results = @mysql_query ($query); // Reload the page. $url = '../b_review.php'; header("Location: $url"); ?> EDIT... again from my code / Get the article id from the URL. $bid = $_GET['bid']; // Start and run the query. $query = "SELECT bname, address, city, state, zip, phone, phone2, fax, website, email, discription, activities, photo, directions, link, map, hours FROM listing WHERE b_id=$bid"; $results = @mysql_query($query); if ($results) { $row = mysql_fetch_array($results, MYSQL_ASSOC); // Save the results into variables. $bname = $row['bname']; $address = $row['address']; $city = $row['city']; $state = $row['state']; $zip = $row['zip']; $phone = $row['phone']; $phone2 = $row['phone2']; $fax = $row['fax']; $website = $row['website']; $email = $row['email']; $discription = $row['discription']; $activities = $row['activities']; $photo = $row['photo']; $directions = $row['directions']; $map = $row['map']; $hours = $row['hours']; $link = $row['link']; } else echo 'An error occured.'; ?> <div id="content"> <div class="innerContent"> <form name="EditDate" action="b_edit.php" method="post"> <table align="center" width="100%" border="0" cellpadding="1" cellspacing="0"> <tr> <td class="title" colspan="2">Edit Business Listing</td> </tr> <tr> <td>Name:</td> <td><input type="text" class="required" name="bname" id="focus" size="40" value="<?php echo $bname; ?>" maxlength="40"></td> </tr> <tr> <td>Address:</td> <td><input type="text" class="required" name="address" size="40" value="<?php echo $address; ?>" maxlength="40"></td> </tr> BLAH BLAH BLAH Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445924 Share on other sites More sharing options...
dare87 Posted January 22, 2008 Share Posted January 22, 2008 <?php <td align="left"><a href="b_edit.php?bname=' . $row['bname'] . '&city=' . $row['city'] . '&bid=' . $row['bid'] . '">Edit</a></td> <td align="left"><a href="auxiliary/b_delete.php?bid=' . $row['bid'] . '" onClick="return sure()">Delete</a></td> ?> Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445925 Share on other sites More sharing options...
dare87 Posted January 22, 2008 Share Posted January 22, 2008 Here is the onclick code.. this will help so you don't delete something <script> function sure(){ var x = confirm("Are you sure?"); if(!x){ return false; } } </script> Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445926 Share on other sites More sharing options...
mmarif4u Posted January 22, 2008 Share Posted January 22, 2008 The best trick here is to make one script. And no need to pass three variables in the link,just ID is enough and surely it will be unique. Just pass the Id in the url with action or something like that and use if statement there like: if(action==edit){ $id=trim($_GET['id']; do edit part } if(action==delete){ $id=trim($_GET['id']; do delete part } And use update command in edit area to do updating. Quote Link to comment https://forums.phpfreaks.com/topic/87181-whts-wrong-with-this-code/#findComment-445929 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.