Search code examples
phpmysqldreamweaverrecord

PHP Show specific record from database that matches the id number


I have a db table 'order_form' and all records are displayed in a page.(I use dreamweaver.) In one of the records, contact no, i made a link Send SMS. If I click that,it should link to a page where i can send that number an sms.basically,the contact no should be displayed in the textfield and should match the one that belongs to the id num. How to do that?

The Send SMS link looks like this and it already displays the matching id num at the url. My probblem is binding the matching contact no which belongs to that id num. I hope I described it right.

 <td><a href="index.php?transaction_num=<?php echo $row_orders['transaction_num']; ?>">Send SMS</a></td> 

enter image description here

After clicking Send SMS, it goes here and should display the matching contact no. in the Recepient textfield.

enter image description here

*NOTE i'm using transaction_num instead of id num.just to let you understand easily i used id num to ask here.


Solution

  • if the same table have the mobile no, say the field name is order_mobile_no, then change the Send SMS link code to the following:

    <td><a href="index.php?order_mobile_no=<?php echo $row_orders['order_mobile_no']; ?>">Send SMS</a></td> 
    

    and in the sending page, add this at the input of the mobile no field (recipient):

    <input type ="text" name="xxx" id="xxx" value="<?php echo $_GET['order_mobile_no']?>" />
    

    name and id = xxx, i am not sure what is that input is named.

    EDIT: to avoid that error, you need to check if that param is exist in the URL, which is done using isset(), so the <input... tag should be :

    <input type ="text" name="xxx" id="xxx" value="<?php if(isset($_GET['order_mobile_no'])){echo $_GET['order_mobile_no'];}else{echo "";}?>" />