forms - SQL/PHP make an array with column name / value for specific unique id -


i have sql table named clients each client stored in row, unique (auto increment) id , column names are: clientname, clientlastname, clientmobile , on.

i want make array retrieve contents of specific client (row) , : clientname => lalala, clientlasthname=>lalalala... , on.

then want display results in html form (non submitable, display) each cell in form has unique id , name same column names of sql db.

i new @ , cant seem it. here's i've done far:

<?php    header("content-type:text/html; charset=utf-8");    if ($_post) {        $link = mysql_connect("localhost","userid","pw");        if (!$link) { die("database connection failed". mysql_error()); }        mysql_set_charset('utf8',$link);        $db_select = mysql_select_db("form2",$link);        if(!$db_select){ die("database selection failed " . mysql_error()); }     }  else { echo "search:"; } ?>  <html>  <head> </head>  <meta http-equiv="content-type" content="text/html; charset=utf-8">   <link rel="stylesheet" href="css/dsearch.css" />  <link rel="stylesheet" href="css/base.css" />  <link type="text/css" href="css/selected/jquery-ui-1.8.18.custom.css" rel="stylesheet" />  <script language="javascript" type="text/javascript" src="js/jquery.min.js"></script>  <script language="javascript" type="text/javascript" src="js/jquery-ui.min.js"></script>  <script language="javascript" type="text/javascript" src="js/dropdowndata.sql/dropdowndata.clients.js"></script>  <script language="javascript" type="text/javascript" src="js/buttons.js"></script>   <body>    <form class="form" id="dsearch" name="dsearch" action="dsearch.php" method="post" enctype="application/x-www-form-urlencoded">       <div class="dsearch">          <li class="ui-widget"><label for="clients">client id: </label><input class="client" name="searchcid" style="width:100px" /></li>         <li class="cell3"><input type="submit" value="Αναζήτηση" style="color:green; width:210px;  " /></li>       </div>    </form>    <div class="results">   <?php    $result1 = mysql_query("select * clients id='$_post[searchcid]'", $link);    if(!$db_select) { die("no data found in db " . mysql_error()); };     $items=array();    while($row = mysql_fetch_array($result1)){      $items[$row['id']] = $row['dlastname'];      /* here need guess,     need fill $items array data formatted mentioned above.    , after want populate form haven't written    values ,any or maybe suggestions on tutorials go study    appreciated.    goes on this: */     }    print_r ($items);  ?>     </div>    </body> </html> <?php    if ($_post) {         mysql_close($link);    }  ?> 

edit: figured out how array

$clinfo=array(); $clinfo=mysql_fetch_assoc($result1);             print_r ($clinfo); 

now need way go put data field id equals id of docinfo array

figured out how little php , jquery, here is:

$(document).ready(function(){       <?php             if($_get){                        foreach($docinfo $key=>$val) {                         echo "$('#" . $key . "').val('" . htmlspecialchars($val) ."');";                        }                }     ?> }); 

this creates jquery line each cell id , fills appropriate value

any comments or improvements extremely appreciated


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -