Jump to content

Need help fixing this code


bchandel

Recommended Posts

I have this code to display data from the database to display web site URL.

 

<a href="<? echo $Web; ?>">Web Site</a></font></td>

 

This works good for field which have website address in database fields. The one which doesn't have web site address it pulls open website address from the browser.

 

Is it is possible to print - in the fields where no website address is in the database field. Thank you!

Link to comment
https://forums.phpfreaks.com/topic/170364-need-help-fixing-this-code/
Share on other sites

Thank you for help. Here is the complete code. Please check this and modify for Web Site and E-mail fields. What I want is only to pull data if available in database or just to leave blank or print "-" where data is not available. Your help is appreciated.

 

 

<html>

<body>

<?php

 

<h1><font color="#0000FF"><left>Search Results:</left></font></h1>

<table border="1" width="100%" cellspacing="5" cellpadding="0">

<tr>

<th><font face="Arial, Helvetica, sans-serif">Name</font></th>

<th><font face="Arial, Helvetica, sans-serif">Last Name</font></th>

<th><font face="Arial, Helvetica, sans-serif">First Name</font></th>

<th><font face="Arial, Helvetica, sans-serif">Phone</font></th>

<th><font face="Arial, Helvetica, sans-serif">Mobile</font></th>

<th><font face="Arial, Helvetica, sans-serif">E-mail</font></th>

<th><font face="Arial, Helvetica, sans-serif">Web</font></th>

<th><font face="Arial, Helvetica, sans-serif">State</font></th>

<th><font face="Arial, Helvetica, sans-serif">Country</font></th>

<th><font face="Arial, Helvetica, sans-serif">Profile</font></th>

 

</tr>

 

<?php

$i=0;

while ($i < $num) {

 

$Name=mysql_result($result,$i,"Name");

$LastName=mysql_result($result,$i,"LastName");

$FirstName=mysql_result($result,$i,"FirstName");

$Phone=mysql_result($result,$i,"Phone");

$Mobile=mysql_result($result,$i,"Mobile");

$Email=mysql_result($result,$i,"Email");

$Web=mysql_result($result,$i,"Web");

$State=mysql_result($result,$i,"State");

$Country=mysql_result($result,$i,"Country");

$Profile=mysql_result($result,$i,"Profile");

 

 

?>

<tr>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Name; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $LastName; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $FirstName; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Phone; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Mobile; ?></font></td>

 

<td align="center"><font face="Arial, Helvetica, sans-serif">

<a href="mailto:<? echo "$Email"; ?>" ?>">E-mail</a></font></td>

 

 

<td align="center"><font face="Arial, Helvetica, sans-serif">

<a href="<? echo "$Web"; ?>" ?>">Web Site</a></font></td>

 

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $State; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Country; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif">

<a href="<? echo "$Profile"; ?>" ?>">Profile</a></font></td>

 

</tr>

 

<?php

 

$i++;

}

?>

</body>

</html>

 

 

 

 

 

 

 

<?php if ($Web != ''): ?>
  <a href="<?php echo $Web; ?>">Web Site</a></font></td>
<?php else: ?>
  <a href="#">Web Site</a></font></td>
<?php endif ?>

Thank you for your message. I changed the code as followed. It still not working. I have some basic knowledge of PHP. I would appreciaye if you can correct if you can correct this line of code.

 

Secondly, I have for table I have these settings:

 

<table border="1" width="100%" cellspacing="5" cellpadding="0">

 

The cells without data looks very different. Any way to fix these.

 

 

Thank you again!

 

 

 

<td align="center"><font face="Arial, Helvetica, sans-serif"><?php if ($Web != ''): ?> <a href="<?php echo $Web; ?>">Web Site</a></font></td>

<?php else: ?> <a href="#">Web Site</a></font></td> <?php endif ?></td>

 

 

where you have...

<a href="<? echo "$Web"; ?>" ?>">Web Site</a>

just replace it with thorpe's code.

 

Same goes for e-mail, just replace $Web with $Email

Is it possible to fix this code so it can work.

 

Thank you!

 

PHP Freaks Forums

August 16, 2009, 12:16:08 AM  Hello bchandel

Show unread posts since last visit.

Show new replies to your posts.

Total time logged in: 48 minutes.

 

    News:We are constantly trying to improve PHP Freaks and these forums, so feel free to go to the PHPFreaks Comments/Suggestions board and point out anything you'd like to see different!

 

Home

Help

Search

Profile

My Messages

Calendar

Members

My Bookmarks

Rules & ToS

Logout

PHP Freaks Forums

 

Profile Info

Summary

Show Stats

Show Posts

Messages

Topics

Attachments

Modify Profile

Account Settings

Forum Profile

Look and Layout

Authentication

Notifications

Personal Messaging

Edit Buddies

Group Membership

Actions

Paid Subscriptions

Show Posts 

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

    Messages    Topics  Attachments   

 

  Messages - bchandel 

Pages: [1] 

1  PHP Coding / PHP Coding Help / Re: Need help fixing this code  on: Yesterday at 01:28:11 AM 

Thank you for your message. I changed the code as followed. It still not working. I have some basic knowledge of PHP. I would appreciaye if you can correct if you can correct this line of code.

 

Secondly, I have for table I have these settings:

 

<table border="1" width="100%" cellspacing="5" cellpadding="0">

 

The cells without data looks very different. Any way to fix these.

 

 

Thank you again!

 

 

 

<td align="center"><font face="Arial, Helvetica, sans-serif"><?php if ($Web != ''): ?> <a href="<?php echo $Web; ?>">Web Site</a></font></td>

<?php else: ?> <a href="#">Web Site</a></font></td> <?php endif ?></td>

 

 

Quote from: MasterACE14 on Yesterday at 01:10:39 AM

where you have...

<a href="<? echo "$Web"; ?>" ?>">Web Site</a>

just replace it with thorpe's code.

 

Same goes for e-mail, just replace $Web with $Email

 

Reply Quote Notify 

 

2  PHP Coding / PHP Coding Help / Re: Need help fixing this code  on: Yesterday at 01:08:01 AM 

Thank you for help. Here is the complete code. Please check this and modify for Web Site and E-mail fields. What I want is only to pull data if available in database or just to leave blank or print "-" where data is not available. Your help is appreciated.

 

 

<html>

<body>

<?php

 

<h1><font color="#0000FF"><left>Search Results:</left></font></h1>

<table border="1" width="100%" cellspacing="5" cellpadding="0">

<tr>

<th><font face="Arial, Helvetica, sans-serif">Name</font></th>

<th><font face="Arial, Helvetica, sans-serif">Last Name</font></th>

<th><font face="Arial, Helvetica, sans-serif">First Name</font></th>

<th><font face="Arial, Helvetica, sans-serif">Phone</font></th>

<th><font face="Arial, Helvetica, sans-serif">Mobile</font></th>

<th><font face="Arial, Helvetica, sans-serif">E-mail</font></th>

<th><font face="Arial, Helvetica, sans-serif">Web</font></th>

<th><font face="Arial, Helvetica, sans-serif">State</font></th>

<th><font face="Arial, Helvetica, sans-serif">Country</font></th>

<th><font face="Arial, Helvetica, sans-serif">Profile</font></th>

 

</tr>

 

<?php

$i=0;

while ($i < $num) {

 

$Name=mysql_result($result,$i,"Name");

$LastName=mysql_result($result,$i,"LastName");

$FirstName=mysql_result($result,$i,"FirstName");

$Phone=mysql_result($result,$i,"Phone");

$Mobile=mysql_result($result,$i,"Mobile");

$Email=mysql_result($result,$i,"Email");

$Web=mysql_result($result,$i,"Web");

$State=mysql_result($result,$i,"State");

$Country=mysql_result($result,$i,"Country");

$Profile=mysql_result($result,$i,"Profile");

 

 

?>

<tr>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Name; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $LastName; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $FirstName; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Phone; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Mobile; ?></font></td>

 

<td align="center"><font face="Arial, Helvetica, sans-serif">

<a href="mailto:<? echo "$Email"; ?>" ?>">E-mail</a></font></td>

 

 

<td align="center"><font face="Arial, Helvetica, sans-serif">

<a href="<? echo "$Web"; ?>" ?>">Web Site</a></font></td>

 

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $State; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif"><? echo $Country; ?></font></td>

<td align="center"><font face="Arial, Helvetica, sans-serif">

<a href="<? echo "$Profile"; ?>" ?>">Profile</a></font></td>

 

</tr>

 

<?php

 

$i++;

}

?>

</body>

</html>

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.