Hi everyone
Here my PHP code .. its looking so bad,but work :s
i have 2 table with the both row is same
//PHP retrive data <? $id = isset($_POST['id']) ? (int)$_POST['id'] : 0; if($id > 0) { //Query the DB $db1 = mysql_query("SELECT * FROM table1 WHERE uid = " . $id); $db2 = mysql_query("SELECT * FROM table2 WHERE uid = " . $id); if($db1 === false && $db2 === false) { die("Database Error"); } echo " <center><b>Get UID '$id' </b></center><br>"; while ($row = mysql_fetch_assoc($db1)){ echo "UID :{$row['uid']} <br> ". "Username : {$row['username']} <br> ". "Phone : {$row['phone']} <br> ". "Email : {$row['acct_email']} <br> ". "--------------------------------<br>"; } while ($row = mysql_fetch_assoc($db2)){ echo "UID :{$row['uid']} <br> ". "Username : {$row['username']} <br> ". "Phone : {$row['phone']} <br> ". "Email : {$row['acct_email']} <br>" . "--------------------------------<br>"; } } ?> //php search <? $searchid = trim($_POST['name']); //check whether the name parsed is empty if($searchid == "") { echo "<center><h2>Please input Serial ID or Searching by Name</h2></center>"; exit(); } $query = "SELECT * FROM table WHERE username LIKE '%$searchid%'"; $query2 = "SELECT * FROM table WHERE username LIKE '%$searchid%'"; $results = mysqli_query($link, $query); $results2 = mysqli_query($link, $query2); if(mysqli_num_rows($results) >= 1) { echo " <center><b>Keyword '$searchid' is found </b></center><br><br>" ; $output = ""; while($row = mysqli_fetch_array($results)) { $output .= "User ID: " . $row['uid'] . "<br />"; $output .= "Username :" . $row['username'] . "<br />"; $output .= "phone: " . $row['phone'] . "<br />"; $output .= "Email: " . $row['acct_email'] . "<br /><br />"; $output .= "--------------------------------<br>"; } } if(mysqli_num_rows($results2) >= 1) { $output2 = ""; while($row = mysqli_fetch_array($results2)) { $output2 .= "User ID: " . $row['uid'] . "<br />"; $output2 .= "Username :" . $row['username'] . "<br />"; $output2 .= "Phone: " . $row['phone']. "<br />"; $output2 .= "Email: " . $row['acct_email'] . "<br />"; $output2 .= "--------------------------------<br>"; } echo "$output $output2"; }
can anyone make this code more structure?
?