Page 1 of 1

Place bold tags on last eight characters of query return

Posted: Sat Nov 14, 2009 7:38 am
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

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

Posted: Sat Nov 14, 2009 2:21 pm
by requinix
substr will give you part of a string.

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

Posted: Sat Nov 14, 2009 5:20 pm
by jeaux
tyvm,
Joe