douqi1625 2014-05-28 11:06
浏览 40

从项目列表中单击选择后,从名称,公司等数据库中获取详细信息

Upon clicking to this page, I am able to edit most of the details in here, but all of the companies were listed to allow the editing of data.

WHAT IS NEEDED: Page A: "Clicked on Company A's edit details" Page B "Show only the edit entries for Company A"

WHAT IS ACTUALLY SHOWN IN THE CODES BELOW: Page A: "Clicked on Company A's edit details" Page B: "Shows all the edit entries for all the companies in the database"

I believe that I should not be using a while loop but since I'm getting here from another page, I would probably need to use a if/else statement to check for it.

In the list to be clicked:

                <!-- popup -->
            <div data-role="popup" id="popupMenu">
                <ul data-role="listview" data-inset="true" >
                    <li data-role="divider" data-theme="a">Choose Action</li>
                    <li><a href="editCompany.php?id=<?php echo $row[$company_id]; ?>">Edit Details</a></li>
                    <li><a href="#">View Jobs</a></li>
                </ul>
            </div>

AND in the edit page:

<?php
            if ($totalCompanies > 0) {
                ?>
                <?php
                while ($row = mysqli_fetch_assoc($result)) {

                    //$id = $row['id'];
                    $company_id = $row['company_id'];
                    $company_name = $row['company_name'];
                    $business_regno = $row['business_regno'];
                    $address = $row['address'];
                    $contact_num = $row['contact_num'];
                    $contact_name = $row['contact_name'];

                ?>
                <form id="editCompany" action = "doCreateCompany.php" method = "post">
                    <label id="company_name">Company Name: </label> 
                    <input type="text" name="company_name" id="company_name" value="<?php echo $company_name ?>">

                    <label id="business_regno">Business Registration Number: </label>
                    <input type="text" name="business_regno" id="business_regno" value="<?php echo $business_regno ?>">

                    <label id="address">Address: </label>
                    <input type="text" name="address" id="address" value="<?php echo $address ?>">

                    <label id="contact_num">Contact Number: </label>
                    <input type="text" name="contact_num" id="contact_num" value="<?php echo $contact_num ?>">

                    <label id="contact_name">Contact Name: </label>
                    <input type="text" name="contact_name" id="contact_name" value="<?php echo $contact_name ?>">

                    <input type="submit" data-theme="b" data-inline="true" value="Save Company Details"/>
                </form>
                <?php
            } // end for loop
            ?>    
            <?php
                    } //end if
            mysqli_close($link);
            ?>
        </div>

Thanks so much!

  • 写回答

1条回答 默认 最新

  • donglaogu3788 2014-05-28 11:21
    关注

    A simple solution would be, if you add ?id= to your editlink. This could look like this:

    echo('<a href="path/to/file.php?id='.$row['company_id'].'">Edit details</a>');
    

    You can then use $_GET['id'] and do a simple select statement with this id which will return only the company you need. But pay attention with the select because the id can be manipulated very easy.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值