PHP and MySQL WP -


i trying accomplish 2 things here code. writing php directly wp page using insert php plugin.

1) query mysql database , return results 1 column 4 columns.

2) make each result own hyperlink directs user new wp page runs new query on page.

i able query show results , turn results dynamic hyperlink, cannot formatting down. right returns result 1 column. here have:

[insert_php]  $servername = "localhost"; $username = "login"; //edited privacy $password = "password"; //edited privacy $database = "database"; //edited privacy  // create connection $conn = new mysqli($servername, $username, $password, $database);  // check connection if ($conn->connect_error) {     die("connection failed: " . $conn->connect_error); }  echo "connected successfully";  //get results database $result = mysqli_query($conn,"select mine mines order mine"); $all_property = array();  //declare array saving property  //showing property echo '<table class="data-table">         <tr class="data-heading">';  //initialize table tag  while ($property = mysqli_fetch_field($result)) {     echo '<td>' . $property->name . '</td>';  //get field name header     array_push($all_property, $property->name);  //save array } echo '</tr>'; //end tr tag  //showing data  while ($row = mysqli_fetch_array($result)) {     echo "<tr>";     foreach ($all_property $item) {         echo "<td><a href='urlhere/$row[$item]'>".$row[$item]. "</a>"."</td>"; //get items using property value     }     echo '</tr>'; } echo "</table>";  [/insert_php] 

thanks can offer.

i'd results (each 1 hyperlink):

image link below

i able work out. still have not gotten results hyperlink array filling in on 4 columns now. here code:

$sql = "select mine mines order mine"; $result = mysqli_query($conn, $sql);  if ($result) {     $data = array();     while($row = $result->fetch_assoc()) {        $data[] = $row['mine'];     }  }   if (is_array($data) && count($data)) { // if array's not empty, create html         //create table & header row        $htmlout="<table><tr>           <th colspan='4'>mine</th></tr>           <tr>        ";          $counter = 1; //keep count of data          foreach ($data $mines) {           //table cell datum           $htmlout .= "<td>$mines</td>\n";            //rows of 4           if ($counter % 4 == 0) {               $htmlout .= "</tr>\n<tr>\n";           }           $counter++;        }  }  $htmlout .= "</tr></table>";   echo $htmlout;   

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -