Jump to content

for updating sql table...


aian04

Recommended Posts

<?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?

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.

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

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.

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??

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.