Jump to content

amansood4u

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

amansood4u's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Dear Guru's, If somebody can guide me on how to make a variable in php code as hyperlink, that should solve my issue. I have $e > which is o/p value(cell) of 1 column and I want to display it as hyperlink. Thanks & regards, Aman
  2. Dear Guru, Thanks for your guidance. I think we are getting very close on this now: As suggested by you, I have changed earlier code to below code: ------------------------------------------ <?php $db_host = 'localhost'; $db_user = 'user'; $db_pwd = 'xxxx'; $database = 'website'; $table = 'uploads'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("select Description, URL from uploads"); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<h1>Table: {$table}</h1>"; echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; echo "<td>" . $row['Description'] . "</td>"; echo "<td><a href='" . $row['URL'] . "'>Link or Script</a></td>"; echo "</tr>\n"; } mysql_free_result($result); ?> </body></html> "tabletest22.php" 47L, 968C written [amansood@gator126 ~/public_html]$ vi tabletest22.php <?php $db_host = 'localhost'; $db_user = 'amansood_1'; $db_pwd = 'simple1u'; $database = 'amansood_site'; $table = 'uploads'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("select Description, URL from uploads"); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<h1>Table: {$table}</h1>"; echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; echo "<td>" . $row['Description'] . "</td>"; echo "<td><a href='" . $row['URL'] . "'>Link or Script</a></td>"; echo "</tr>\n"; } mysql_free_result($result); ?> </body></html> ------------------------------------------------------- The o/p to this code is as follows: Table: uploads Description URL Link or Script Description is NULL ( Don't know why is that :-( ) Also, the "Link or Script" Hyperlink points to Current page, I want it to point to actual value of column URL which is "http://servername.domain.com/directly/Script.sql" I need this Link on URL column ( with above value) to enable users click it and download this particular script which currently resides in server file system. Only, Complete URl is mentioned in URL column. Apologise for confusing you earlier. Hope I am bit clear this time otherwise feel free to ask, I can give call and expalin as well :-( Thanks & regards, Aman
  3. Dear Guru's, I have downlaoded other way of doing o/p for same query through net: <html> <body> <?php $username="username"; $password="xxxxx"; $database="databse"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT Description, URL FROM uploads"; $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Description</font></th> <th><font face="Arial, Helvetica, sans-serif">Url</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"Description"); $f2=mysql_result($result,$i,"URL"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f1; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> </tr> <?php $i++; } ?> </body> </html> Is it easier to change something in this to get URl has Hyperlink and value displayed as link? Thanks & regards, Aman
  4. Thanks Dear Guru's!!!! It finally is showing Hyperlinks to my file but for all columns and the Value of everything has been changed to"Link or Script". Here is current output: Table: uploads ID Type URL Link or Script Link or Script Link or Script Though it is giving correct link. But I need link for only URL column and real values for rest two columns? Please could you suggest.. Thanks & regards, Aman
  5. Just to make things more clear the URL column has value like http://servername.domain.com/folder/filename.sql So, it's complete nothing to add or substract. If, cutting it short is the option for href to work i can easily do that as well. Thanks & regards, Aman
  6. Thanks Guru for so prompt reply! Here is the code I am using: <?php $db_host = 'localhost'; $db_user = 'sitedb'; $db_pwd = 'xxxxx'; $database = 'web_site'; $table = 'uploads'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); // sending query $result = mysql_query("select id ID, resource_type Type, URL from uploads"); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<h1>Table: {$table}</h1>"; echo "<table border='1'><tr>"; // printing table headers for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?> </body></html> Here URL column has value like servername.domin.com/folder/file.sql need to show it as Word "Link" or "Script". When user click that they should be able to download the file. Thanks once again!
  7. Hi There, Apologies for asking so trial question but i am very new to php. I have stored my complete URL in URL column of mysql database and now want to retrive it as link. Want to show in my php Page hyperlink named "Link" which will enable user to click the link and downlaod file which resides in my filesystem. Have been banging my head on this from last 3-4 days now but didn't get anything. Please could any of you experts can help on this.. Thanks in advance!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.