Mysql
 sql >> डेटाबेस >  >> RDS >> Mysql

चयन करें * तालिका से जहां चर '$ चर' की तरह का उपयोग कर क्लिक किए गए लिंक पर प्रासंगिक MySQL जानकारी आउटपुट नहीं कर सकता

मैं समझ सकता हूं कि जब पहली बार शुरुआत की जाती है तो यह कैसा होता है। एक बार जब आप अपने दिमाग को इसके मूल भागों के इर्द-गिर्द लपेट लेते हैं तो बाकी चीजें प्रवाहित हो जाती हैं।

चूंकि आपने एक बेहतर तरीके के लिए कहा है, इसलिए मैं अपनी सभी परियोजनाओं में व्यक्तिगत रूप से उपयोग की जाने वाली कक्षा का सुझाव देने जा रहा हूं।

https://github.com/joshcam/PHP-MySQLi-Database-Class ए>

बेशक ऊपर दिए गए लिंक से सरल MYSQLI वर्ग को डाउनलोड करना न भूलें और इसे वैसे ही शामिल करें जैसे मैं आपके प्रोजेक्ट में नीचे करता हूं। अन्यथा इनमें से कोई भी काम नहीं करेगा।

यहां पहला पृष्ठ है जिसमें आपके व्यक्तियों के सभी उपयोगकर्ताओं के साथ तालिका शामिल है डीबी तालिका। हम उन्हें एक साधारण संपादन/दृश्य बटन वाली तालिका में सूचीबद्ध करते हैं।

पेज 1

 <?php 
        require_once('Mysqlidb.php');

        //After that, create a new instance of the class.

    $db = new Mysqlidb('host', 'username', 'password', 'databaseName');

    //a simple select statement to get all users in the DB table persons
    $users = $db->get('persons'); //contains an Array of all users 


    ?>
    <html>
    <head>



    <link  type="text/css" href="style.css">
    </head>
    <body>

<table>

    <th>
        First Name
    </th>
    <th>
        Last Name
    </th>
    <th>&nbsp;</th>

<?php 

//loops through each user in the persons DB table
//the id in the third <td> assumes you use id as the primary field of this DB table persons
foreach ($users as $user){ ?>
    <tr>
        <td>
            <?php echo $user['fname'];?>
        </td>
        <td>
            <?php echo $user['lname'];?>
        </td>
        <td>
        <a href="insert.php?id=<?php echo $user['id']; ?>"/>Edit/View</a>   
        </td>
    </tr>

<?php } ?>

</table>
</body>
    </html>

तो यह आपका पहला पेज समाप्त करता है। अब आपको इस कोड को अपने दूसरे पेज पर शामिल करना होगा जिसे हम इन्सर्ट.php कहते हैं।

पेज 2

<!--add this to your insert page-->

 <?php 
        require_once('Mysqlidb.php');

        //After that, create a new instance of the class.

    $db = new Mysqlidb('host', 'username', 'password', 'databaseName');

    //a simple select statement to get all the user where the GET 
    //variable equals their ID in the persons table
    //(the GET is the ?id=xxxx in the url link clicked)

    $db->where ("id", $_GET['id']);
    $user = $db->getOne('persons'); //contains an Array of the user

    ?>

<html>
<head>



<link  type="text/css" href="style.css">
</head>
<body>
    <table>

<th>
    First Name
</th>
<th>
    Last Name
</th>
<th>user ID</th>


<tr>
    <td>
        <?php echo $user['fname'];?>
    </td>
    <td>
        <?php echo $user['lname'];?>
    </td>
    <td>
    <?php echo $user['id']; ?>  
    </td>
</tr>

</body>
</html>


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. पैरामीटर '@myLeft' को परिभाषित किया जाना चाहिए

  2. ग्रुप बाय क्लॉज में एक चुनिंदा अभिव्यक्ति के परिणाम का पुन:उपयोग करें?

  3. कोडइग्निटर के साथ बैच अपडेट करें

  4. MySQL नकली प्रविष्टियों की अनुमति देता है जब इसमें शामिल फ़ील्ड में से एक NULL होता है

  5. दौड़ की स्थिति पर चुनिंदा फाउंड_रो को तोड़ने से कैसे रोकें?