CARI Infonet

 Forgot password?
 Register

ADVERTISEMENT

View: 3765|Reply: 10

Papar Maklumat terakhir dalam database

[Copy link]
Post time 16-1-2012 04:01 PM | Show all posts |Read mode
Assalam.. Ada tak coding untuk memaparkan maklumat akhir dalam database guna php?
Reply

Use magic Report


ADVERTISEMENT


Post time 16-1-2012 05:30 PM | Show all posts
guna syntax dalam database je.
kalau mysql ada beberapa cara. contohnya

SELECT * FROM table ORDER BY table.id DESC LIMIT 1

Rate

1

View Rating Log

Reply

Use magic Report

 Author| Post time 16-1-2012 11:30 PM | Show all posts
  1. <?php
  2.                                                   include "connect.php";

  3. $id= $_POST['id_gambar']; //get the nama value from form
  4. $q = "SELECT * from gambar where id_gambar like '%$_POST[id_gambar]%' "; //query to get the search result

  5. $result = mysql_query($q); //execute the query $q
  6. echo "<center>";
  7. echo "<h2> Hasil Carian </h2>";
  8. echo "<table bgcolor='white' border='1' cellpadding='5' cellspacing='8'>";
  9. echo "
  10. <tr bgcolor='orange'>
  11. <td><font color='black'>No : </font></td>
  12. <td><font color='black'>Nama Gambar :</font> </td>
  13. <td><font color='black'>Lokasi : </font></td>
  14. </tr>";
  15. while ($data = mysql_fetch_array($result)) {  //fetch the result from query into an array
  16. echo "
  17. <tr>
  18. <td><font color='black'>".$data['id_gambar']."</font></td>
  19. <td><font color='black'>".$data['namaGambar']."</font></td>
  20. <td><font color='black'>".$data['lokasi']."</font></td>
  21. </tr>";
  22. }
  23. echo "</table>";
  24. ?>
Copy the Code

nie koding aq, untuk wat carian. bila aq tekan cari, semua maklumat yg keluar, bukannya apa yang aq cari. minx tlg tgk'kn boleh?

n pasal yang masalah ats td, aq nk paparkan maklumat yang telah aq masukkan. Contoh, setelah isi semua maklumat, pengguna tekan hantar, dan akan dapat satu paparan maklumat yang telah dimasukkan td. Ada xcontoh coding 2?

Reply 2# kmkd
Reply

Use magic Report

Post time 17-1-2012 12:25 AM | Show all posts
Post Last Edit by kmkd at 17-1-2012 00:29

rujuk ln5. macam ni ke
  1. "SELECT * from gambar where id_gambar like '%$_POST[id_gambar]%' "
Copy the Code
macam ni?
  1. "SELECT * from gambar where id_gambar like '%".$id."%' "
Copy the Code
sebab kalau kau letak as '%$_POST[id_gambar]%', nanti query dalam db akan kekal jadi gitu. dia tak tukar ke value yang kau nak. sebab kau still dalam string. setahu aku la.
btw, kau dah masukkan dia as $id, maka gunakan.

selalunya masalah pada semua keluar semua tak keluar tu puncanya dari db query. pastikan tu betul dulu baru masuk dalam code

kalau nak tahu apa query yang dia pass, sebelum jalankan query, print_r;exit(); atau echo;exit(); dan try buat query pada sql editor eg. phpmyadmin untuk tengok betul ke query tu macam yang kau nak.

Rate

1

View Rating Log

Reply

Use magic Report

Post time 17-1-2012 12:27 AM | Show all posts
kau kod guna apa ni? maksud aku IDE? dreamweaver?
Reply

Use magic Report

 Author| Post time 17-1-2012 12:57 AM | Show all posts
Reply 4# kmkd


   prob untuk carian tu aq dh settle kn.. sepatutnya coding mcm ini.. aq lupa nk tukar pada line 1 ja nama POST tu... thnks bro..
  1. $id= $_POST['noIklan']; //get the nama value from form
  2. $q = "SELECT * from gambar where id_gambar like '%$_POST[noIklan]%' "; //query to get the search result
Copy the Code




prob tu papar tu bro ada solution x?
Reply

Use magic Report

Follow Us
 Author| Post time 17-1-2012 12:59 AM | Show all posts
Reply 5# kmkd


   dreamweaver... cs4
Reply

Use magic Report

Post time 17-1-2012 09:32 AM | Show all posts

Papar Maklumat terakhir dalam database

Untuk paparkan tu kau boleh suruh dia bukak satu page lepas kau berjaya save.

Aku tak pasti untuk buat dalam pure php sebab aku guna codeigniter n cake.


(posted by mobile)
Reply

Use magic Report


ADVERTISEMENT


Post time 17-1-2012 02:58 PM | Show all posts
Reply  kmkd


   prob untuk carian tu aq dh settle kn.. sepatutnya coding mcm ini.. aq lupa nk t ...
DjKiller Post at 17-1-2012 00:57



    hok alowh!
Reply

Use magic Report

Post time 17-1-2012 05:20 PM | Show all posts
guna nih utk dapatkan id yg terakhir di masukkan.
  1. $id = mysql_insert_id()
Copy the Code
Reply

Use magic Report

 Author| Post time 2-2-2012 10:52 PM | Show all posts
Reply 9# hanazz_88


    hehehe~
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CARI Infonet

24-4-2024 02:19 AM GMT+8 , Processed in 0.292762 second(s), 38 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list