[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

php and mysql help what the best why to do this.....

Posted on 2014-01-27
5
Medium Priority
?
531 Views
Last Modified: 2014-01-27
Hello i have this code

<?php



$host = "localhost";
$user = "123";
$pass = "123";


$r = mysql_connect($host, $user, $pass);

if (!$r) {
    echo "Could not connect to server\n";
    trigger_error(mysql_error(), E_USER_ERROR);
} else {
    echo "Connection established <br>";
}

@mysql_select_db("patient_regester") or die( "Unable to select database");
$query="Select * FROM kfhh Order by Room_id";
$result=mysql_query($query);
$num=mysql_numrows($result);





echo mysql_get_server_info() . "<br>";





?>

<br><table width='50%' border='1'>

  <tr align='center'>
    <td>Room Number</td>
    <td>Occupancy Status</td>
    <td>Last Name</td>
    <td>First Name</td>
    <td>LOC</td>
    <td>Visitors</td>
  </tr>

<?php

$i=0;
$n=1;





while ($i < $num) {


$name_Occupancy="Occupancy".$n;


$Room=mysql_result($result,$i,"Room_id");
$Occupancy=mysql_result($result,$i,"Occupancy");
$Last_name=mysql_result($result,$i,"Last_name");
$First_Name=mysql_result($result,$i,"First_Name");
$LOC=mysql_result($result,$i,"LOC");
$Visitors=mysql_result($result,$i,"Visitors");





?>
 <form >


  <tr>
    <td><?php echo $Room ?></td>


<td> <?php echo $Occupancy ?> </td>

    <td> <?php echo $Last_name ?> </td>
    <td> <?php echo $First_Name ?></td>
    <td> <?php echo $LOC ?></td>
    <td> <?php echo $Visitors ?></td>
  </tr>

<?php


$i++;
$n++;

}
mysql_close();

?>

</table>

Open in new window


What displays is this



Would it be easier to have a "edit" button next to each Room number. When the user clicks the edit it will let them edit just that row.

Or have the Occupancy Status, LOC, and Visitors and drop down box and the last and first name boxes be input fields.

Then have one button for save.

This info will be changed a lot thought the day so i want to make it very easy to use.
0
Comment
Question by:armasmike
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:Computer Guy
ID: 39812504
There are a couple of questions to ask, will the same person who is using this software be the one editing it?

You have two ways to make this happen.

YOUR WAY: Have the Occupancy Status, LOC, and Visitors and drop down box and the last and first name boxes be input fields.

MY WAY: I would create 2 pages: Edit and View

I know you mention the dropdown box, personally I would use a checkbox, that way with a simple click, you can make the change, though you can still get away with the dropdowns.

On the view page, have a link or button for updating

On the edit page, have a link or button for saving, and recirecting to the view page.
0
 
LVL 44

Expert Comment

by:Chris Stanyon
ID: 39812564
Modern approach would be to have an edit link / button for each row, and on click opens up the record in a popup dialog box (or even in-line - replacing the text with form inputs / drop downs). When clicking on save, either in the dialog popup or inline, you simply use AJAX to post the info back to the database - everything stays in one page and is more intuitive and responsive.

The idea of posting back and forward between pages is old-school, and having all the options in form fields right away just looks ugly :)
0
 
LVL 44

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 1000 total points
ID: 39812569
Having said all that, your code will need a major overhaul - you need to get away from using the mysql library ASAP - it's deprecated so you'll need to switch to mysqi or PDO
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 39812639
This article shows a general design pattern for PHP / MySQL table maintenance scripts.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12335-PHP-and-MySQLi-Table-Maintenance.html

This article will help you make the required move away from the MySQL extension.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/PHP_Databases/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

And this article will help you avoid some of the less-well-done programming practices.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12293-AntiPHPatterns-and-AntiPHPractices.html
0
 

Author Closing Comment

by:armasmike
ID: 39812824
Thank you both Chris Stanyon i like your way of doing it on all one page and Ray Paseur thank you for the links to mysqli
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question