Hi all, how can I make a link for the data get from database? Can anyone help me.. thanks~ <?php $sql = "SELECT * from institution where type='foreign'"; $result = mysql_query($sql) or die("SQL select statement failed"); // execute query $result=mysql_query($sql); while ($row = mysql_fetch_array($result)) { $Iname = $row["i_name"]; $Website = $row["website"]; $Address = $row["address"]; echo "<table>"; echo "<tr><th>Institution Name:</th><td>$Iname</td></tr>"; echo "<tr><th>Website :</th><td>$Website</td></tr>"; echo "<tr><th>Address :</th><td>$Address</td></tr>"; echo "</table><br>"; } ?> PHP:
<?php $sql = "SELECT * from institution where type='foreign'"; $result = mysql_query($sql) or die("SQL select statement failed"); // execute query $result=mysql_query($sql); echo "<table>"; while ($row = mysql_fetch_array($result)) { $Iname = $row["i_name"]; $Website = $row["website"]; $Address = $row["address"]; echo "<tr><th>Institution Name:</th><td>$Iname</td></tr>"; echo "<tr><th>Website :</th><td>$Website</td></tr>"; echo "<tr><th>Address :</th><td>$Address</td></tr>"; echo "<br>"; } echo "</table>"; ?> PHP: i guess this is what u needed right?
yes i put <table> code out of the loop. very small but effective change. this will put everything in one table.i actually read title of a different post and saw a different post. i didn't read wat u wanted sry for that.i hope that u made sure that mysal database is connected.
ahh I think I know what you want.... a link to a file that will connect to the database ? If you already have a db connection file skip this part or ... 1, Create a file called db.php place the following into it, upload it to your server <?php // db options define('DB_NAME', "myDatabase"); define('DB_USER', "username"); define('DB_PASSWORD', "password"); define('DB_HOST', "localhost"); mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); mysql_select_db(DB_NAME); ?> PHP: 2, Next add the following to your code above like this: <?php include "db.php"; // this is how you connect to the database $sql = "SELECT * from institution where type='foreign'"; $result = mysql_query($sql) or die("SQL select statement failed"); // execute query $result=mysql_query($sql); echo "<table>"; while ($row = mysql_fetch_array($result)) { $Iname = $row["i_name"]; $Website = $row["website"]; $Address = $row["address"]; echo "<tr><th>Institution Name:</th><td>$Iname</td></tr>"; echo "<tr><th>Website :</th><td>$Website</td></tr>"; echo "<tr><th>Address :</th><td>$Address</td></tr>"; echo "<br>"; } echo "</table>"; ?> PHP:
What I want is when data retrieved from database then the <a href="" >$data</a> something like this...
I have another problem... how to do second selection menus change depend on first selection menus. Exp: After user select Institute Name then the selection menus of School Name change depend on Institute Name..Using javascript & php.. thanks~