Place bold tags on last eight characters of query return

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeaux
Forum Commoner
Posts: 25
Joined: Sun Aug 24, 2008 5:11 pm

Place bold tags on last eight characters of query return

Post by jeaux »

I'm returning from a MySQL DB a vin # for a car and would like to highlight the last 8 characters. Looking for some clues as to where to start my research.

this would be ideal:

Code: Select all

 
<?php
$con = mysql_connect("DELETED");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 
mysql_select_db("cars1", $con);
 
$result = mysql_query("SELECT * FROM cars WHERE id = $_POST[carid]");
 
while($row = mysql_fetch_array($result))
  {
  echo $row['VIN'];//Somehow just display the first 9 characters of $row['VIN']
?>
<strong>
<?
  echo $row['VIN'];//Somehow just display the last 8 characters $row['VIN']
?>
</strong>
 
Many thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Place bold tags on last eight characters of query return

Post by requinix »

substr will give you part of a string.
jeaux
Forum Commoner
Posts: 25
Joined: Sun Aug 24, 2008 5:11 pm

Re: Place bold tags on last eight characters of query return

Post by jeaux »

tyvm,
Joe
Post Reply