
kevin66
Members-
Posts
20 -
Joined
-
Last visited
Never
Everything posted by kevin66
-
Hi, I have been searching everywhere to try to figure out how to restrict the number of chararacters shown when I do a while loop of data. The one I want to restrict is Property_Short_Description here - <?php echo "2.gif vspace=5 border=0><br />"; echo $row['Property_Short_Description'];} ?> Thanks so much
-
Define exchange rate and multiple value to data
kevin66 replied to kevin66's topic in PHP Coding Help
I got it working like you said but it doesnt write 2 decimal places , how can i force it to do this? <?php if(!empty($row['Band_3_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_3_Price']*0.4."</div></div>"; } ?> -
Define exchange rate and multiple value to data
kevin66 replied to kevin66's topic in PHP Coding Help
Exactly, but when I use it like - if(!empty($row['Band_1_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_1_Price']*2.22."</div></div>"; } it gives an error I think the prob is when I add the </div> Can I define it first and then use when i write as I need to write it in 6 places -
Hi, am trying without much luck, (I am new), to define an exchange rate on the page and then mutiplying it by a value I am extracting from a mysql db. I write the value as below normally but having trouble writing this entry and multiplying it by my defined exchanged rate of say 2.22. <?php if(!empty($row['Band_1_Price'])) {echo "<div class=pricing_box_right2>£".$row['Band_1_Price']."</div></div>"; } ?> Thanks so much.
-
Figured my error I had id instead of ID. Works fine now. Thanks so much.
-
Sorry made a mistake my final code is - <?php // Connect to server and select database. mysql_connect('localhost', 'xxxxxx', 'xxxxxx') or die("Error: ".mysql_error()); mysql_select_db("dalyanhotels"); $id = $_POST['id']; $Property_Rating = $_POST['Property_Rating']; // update data in mysql database $sql="UPDATE properties SET Property_Rating='$Property_Rating' WHERE id='$id'"; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; } else { echo "ERROR"; } ?>
-
Thanks for your prompt post. As you figured I am very new to php. The code - <td align="center"> </td><td align="center"><strong>Property_Name</strong></td><td align="center"><strong>roperty_Rating</strong></td><td align="center"><strong>Property_Address</strong></td></tr> Was just text there as I wanted to just update Property_Rating field. I do have other fields but was just testing one. Do I have to list them all? I changed the final code to - <?php // Connect to server and select database. mysql_connect('localhost', 'xxx', 'xxxxx') or die("Error: ".mysql_error()); //add your DB username and password mysql_select_db("xxxxx");//add your dbname $id = $_POST['id']; $Property_Name = $_POST['Property_Name']; // update data in mysql database $sql="UPDATE properties SET Property_Name='$Property_Name' WHERE id='$id'"; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; } else { echo "ERROR"; } ?> But still no change in db on final submit. Any ideas? Thanks a million. MOD EDIT: code tags added.
-
Hi, I am extracting data from a mysql db to then edit and update back into the db and use below to list items first - <?php // Connect to server and select database. mysql_connect('localhost', 'xxxxxxxxx', 'xxxxxxxxxxxxx') or die("Error: ".mysql_error()); mysql_select_db("xxxxxxxxx"); $sql="SELECT * FROM properties"; $result=mysql_query($sql); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td> <table width="400" border="1" cellspacing="0" cellpadding="3"> <tr> <td colspan="4"><strong>List data from mysql </strong> </td> </tr> <tr> <td align="center"><strong>Name</strong></td> <td align="center"><strong>Lastname</strong></td> <td align="center"><strong>Email</strong></td> <td align="center"><strong>Update</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td><? echo $rows['Property_Rating']; ?></td> <td align="center"><a href="update.php?id=<? echo $rows['ID']; ?>">update</a></td> </tr> <?php } ?> </table> </td> </tr> </table> <?php mysql_close(); ?> I then go next page where I show data and allow editing - <?php // Connect to server and select database. mysql_connect('localhost', 'xxxxxxxxx', 'xxxxxxxxxxxxx') or die("Error: ".mysql_error()); mysql_select_db("xxxxxxxxx"); // get value of id that sent from address bar $id=$_GET['id']; // Retrieve data from database $sql="SELECT * FROM properties WHERE id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); ?> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <form name="form1" method="post" action="update_ac.php"> <td> <table width="100%" border="0" cellspacing="1" cellpadding="0"> <tr> <td> </td> <td colspan="3"><strong>Update data in mysql</strong> </td> </tr> <tr> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td align="center"> </td> <td align="center"><strong>Property_Name</strong></td> <td align="center"><strong>roperty_Rating</strong></td> <td align="center"><strong>Property_Address</strong></td> </tr> <tr> <td> </td> <td align="center"><input name="Property_Rating" type="text" id="Property_Rating" value="<? echo $rows['Property_Rating']; ?>"></td> </tr> <tr> <td> </td> <td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td> <td align="center"><input type="submit" name="Submit" value="Submit"></td> <td> </td> </tr> </table> </td> </form> </tr> </table> <? // close connection mysql_close(); ?> And then the update page - <?php // Connect to server and select database. mysql_connect('localhost', 'xxxxxxxxx', 'xxxxxxxxxxxxx') or die("Error: ".mysql_error()); mysql_select_db("xxxxxxxxx"); // update data in mysql database $sql="UPDATE properties SET Property_Name='$Property_Name' WHERE id='$id'"; $result=mysql_query($sql); // if successfully updated. if($result){ echo "Successful"; } else { echo "ERROR"; } ?> Everything seems ok but when I edit the data and submit I get the success message but data not changed in db. Any ideas? Thanks. MOD EDIT: code tags added.
-
Thanks I have looked at this. I can only see examples where it is used when creating tables but not when inserting a new row. Any ideas on how? I am very new to php/mysql. Here is my code so far - $name = $_POST['name']; $email = $_POST['email']; $sql = "INSERT INTO properties SET Band_4_Room='$name', Band_4_Price='$email'"; if (@mysql_query($sql)) { echo('<p>New employee added</p>'); } else { echo('<p>Error adding new employee: ' . mysql_error() . '</p>'); } // This finds the id of the row once it has been added... $id = MYSQL_INSERT_ID(); // Display it... ECHO $id;
-
Hi. When I add data to a table from a php form, the new entry is say 7 but the previous one was 2. It skips numbers when adding a new row. Any help please. Can I define the next ID when I submit the data? Thanks
-
I understand now. Thanks.
-
Thanks for the info. When you say restructing the table, what do you mean? The other fields are OK as I just use the whole chunk. Just this one I want to write as a list. Thanks.
-
Yes, attached are screenshots of db. Code I am using is - <?php // Make a MySQL Connection mysql_connect("localhost", "???????????", "?????????") or die(mysql_error()); mysql_select_db("dalyanhotels") or die(mysql_error()); $query = mysql_query("SELECT * FROM properties") or die(mysql_error()); \\ use your table names echo '<ul>'; while($result = mysql_fetch_array($query)) { echo '<li>'.$result['Property_Facilities_General'].'</li>'; } echo '</ul>'; ?> At the moment the code kills the whole page and is blank when i use this code. Really appreciate your help. [attachment deleted by admin]
-
Really appreciate your help as I may not have explained this well. The chunk of code below is in one field (not several) called Property_Facilities_General. Air conditioning in rooms 24 Hour Reception Smoking rooms available Is what I want possible? Thanks.
-
Thanks so much. I am very new to php, as you have probably figured. I am having trouble getting this to work. This is what I have - <?php $query = $row['Property_Facilities_General']; echo '<ul>'; while($result = mysql_fetch_array($query)) { echo '<li>'.$result['column_name'].'</li>'; } echo '</ul>'; ?> Any ideas? Thank you.
-
Hi, I have a chunk of text I am pulling from a mysql db like below. Air conditioning in rooms 24 Hour Reception Smoking rooms available How can I write this into - <ul> <li>Air conditioning in rooms</li> <li>24 Hour Reception</li> <li>Smoking rooms available</li> </ul> Many thanks.
-
Thanks. You are the man.
-
Wow, so fast - thank you - works perfectly. As you probably gathered I am very new to this. Can I please ask another question. How can avoid using say /Test%20Hotel/ or /Test%20Hotel%20Name/ in the url as the db entry is Test Hotel or Test Hotel Name. I would like to use Test-Hotel or Test-Hotel-Name in the url. Many thanks.
-
Hi, I have the following mqsql query which works fine on my page called property.php <?php $result = mysql_query("SELECT * FROM properties WHERE Property_Name='Test Hotel'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo "Property Name: ".$row['Property_Name']; echo "<br>Property Rating: ".$row['Property_Rating']; echo "<br>Property Address: ".$row['Property_Address']; ?> Where I use the value of 'Test Hotel' for Property Name in above, how can I insert this value from a url parameter like /property.php?propertyname=Test Hotel? Thanks so much.
-
Hi, I am realtively new to php but getting there. What I am trying to do is use a url like www.thebestcats.com/black-cats or www.thebestcats.com/black-cats.html (I am using htaccess to run php on .html pages), to then query mysql db and echo out all the data for row 'Black Cats'. I would appreciate any help on this or any tutorials along these lines. Thanks so much.