aian04 Posted October 6, 2007 Share Posted October 6, 2007 guys how to do the clickable html table for updating... just click what u want to update in the html table... i think that's possible.. but i dnt knw how... any suggestion experts... Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/ Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 take a second, read what you post and make a coherent statement and we will try and help. Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363436 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td><? echo $rows['Res_id'];?> </td> <td><a style="text-decoration:none;" name="checkin" href="update.php"><? echo $rows['check_in'];?></a></td> <td><a style="text-decoration:none;" name="nyts" href="update.php"><? echo $rows['night_per_stay'];?></a></td> <td><a style="text-decoration:none;" name="r_no" href="update.php"><? echo $rows['R_no']; ?></a></td> <td><a style="text-decoration:none;" name="pac" href="update.php"><? echo $rows['pac_name']; ?></a></td> <td><? echo $rows['Cid']; ?> </td> </tr> <?php is this correct?? i use a href and put a name on it to use it for updating?? for now this is my idea for clickable updating... for my update.php how can i get the name of the chosen field in the html table?? and then update it?? experts how? Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363483 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 um not exactly. Don't break out of php stay in it and echo out the html and don't use the <? short hand opener use the full <?php sorta like <?php while($row = mysql_fetch_assoc($result){ echo "<tr>"; echo "<td>".$row['fieldname']."</td>"; echo "</tr>"; } ?> that is the idea. Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363486 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 ohh ok.. but it doesnt matter coz its workin anyway.. my question on this is how will i update the chosen field.. i mean how to get the selected field and update it.. Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363489 Share on other sites More sharing options...
BlueSkyIS Posted October 6, 2007 Share Posted October 6, 2007 Don't break out of php stay in it and echo out the html and don't use the <? short hand opener use the full <?php curious, why? if short tags are on, it takes less typing to just use <?. i'd even drop the echo: <?=$rows['R_no']?> // don't even need a semi-colon, though i prefer it Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363490 Share on other sites More sharing options...
cooldude832 Posted October 6, 2007 Share Posted October 6, 2007 Its the principle of the thing, short tags aren't going to always be on, secondly there is an attempt to uniform php sorta like w3 is doing with xhtml. If you can't write it in a uniform method that is easy to read for everyone, then it becomes hard to diagnostic and so forth. Secondly php is an extremely bloated language that takes a lot longer than it should to process. This is because of the open-ended ness of the modules of it. If a uniform system could be built and all the bloating removed it run way more efficiently. Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363531 Share on other sites More sharing options...
aian04 Posted October 6, 2007 Author Share Posted October 6, 2007 ok here is my table code <?php $host="localhost"; $username="root"; $password="tmc"; $db_name="tgp"; $tbl_name="reservation"; $id=$_COOKIE['ID']; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name join packages on reservation.pac_id = packages.pac_id where Cid ='$id'"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <html> <head><link href="interface design/css.css" rel="stylesheet" type="text/css"> <script language="javascript"> function hover(FRM,BTN) { window.document.forms[FRM].elements[bTN].style.color = "#6666AA"; window.document.forms[FRM].elements[bTN].style.backgroundColor = "#EEEEF4"; window.document.forms[FRM].elements[bTN].style.borderColor = "#9999DD"; } function out(FRM,BTN) { window.document.forms[FRM].elements[bTN].style.color = "#888888"; window.document.forms[FRM].elements[bTN].style.backgroundColor = "#EEEEEE"; window.document.forms[FRM].elements[bTN].style.borderColor = "#BBBBBB"; } </script> </head> <body align="center"> <form action="http://localhost:6080/aian/update.php" method="post" name="form"> <table class="ret" width="400" border="0" cellpadding="10" cellspacing="3" background="interface design/logo/member.jpg"> <tr> <td colspan="6" align="center"><strong>Reservatio History</strong> </td> </tr> <tr> <td align="center">Reservation ID</td> <td align="center"><strong>Check in Date</strong></td> <td align="center"><strong>No. of nights</strong></td> <td align="center"><strong>Room Number</strong></td> <td align="center"><strong>Specials And Packages</strong></td> <td align="center"><strong>Customer ID</strong></td> </tr> <?php while($rows=mysql_fetch_assoc($result)){ ?> <tr> <td><? echo $rows['Res_id'];?> </td> <td><input type="submit" class="groovybutton2" name="checkin" value="<? echo $rows['check_in'];?>"></td> <td><input type="submit" class="groovybutton2" name="nyts" value="<? echo $rows['night_per_stay'];?>"></td> <td><input type="submit" class="groovybutton2" name="r_no" value="<? echo $rows['R_no']; ?>"></td> <td><input type="submit" class="groovybutton2" name="pac" value="<? echo $rows['pac_name']; ?>"></td> <td><? echo $rows['Cid']; ?></td> </tr> <?php } @mysql_free_result($pac); ?> </table> </body> </html> <? @mysql_close();?> then this is my update.php <html> <head><link href="interface design/css.css" rel="stylesheet" type="text/css"> </head> <body class="ret"> <?php @mysql_connect ("localhost", "root", "tmc") or die (mysql_error()); @mysql_select_db("tgp")or die(mysql_error()); $checkin=$_POST['checkin']; $nyt=$_POST['nyts']; $r=$_POST['r_no']; $pac=$_POST['pac']; if($_POST['form'] == $checkin){ echo "$checkin"; } ?> </body> </html> im just trying to print it out first to see if its workin... it doesnt give me a result.. any suggestions guys?? Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363532 Share on other sites More sharing options...
aian04 Posted October 7, 2007 Author Share Posted October 7, 2007 guys u get my idea... i need help here.... Quote Link to comment https://forums.phpfreaks.com/topic/72105-for-updating-sql-table/#findComment-363927 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.