Using javascript in php
Posted: Tue Feb 01, 2005 3:22 pm
I'm working on a dynamic system that exports a set of images with thumbnails, and the ability to click on the thumbnails and show them in the larger image viewer. The problem I'm having is I cannot get the images to switch to the larger viewer, because of the limitations of javascript and php compatibility. Is it possible to call a javascript function from php? If not, what do you recommend for calling a function from a dynamic php system. I will post code below.
Can you please let me know what you recommend or what options I have.
Thanks,
TheDro
Code: Select all
<?
// Connecting, selecting database
$link = mysql_connect('localhost', 'autox_autoxdbcon', 'audi')
or die('Could not connect: ' . mysql_error());
mysql_select_db('autox_autox') or die('Could not select database');
$query = "SELECT * FROM `forsale` GROUP BY `year` ORDER BY `year`";
$result = mysql_query($query) or die(mysql_error());
while ($values = mysql_fetch_array($result))
{
$descformat = nl2br($valuesїdesc]);
echo "<table width='700' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><b><font size='+1'>$valuesїyear] $valuesїmodel]</font></b></td>
</tr>
</table>
<table width='700' height='246' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='200'><b><font color='red' size='+1'>Price: $valuesїprice]</font></b></td>
<td width='226'>Vin: $valuesїvin]</td>
<td width='274'> </td>
</tr>
<tr>
<td height='227'><img src='images/forsale/$valuesїimage]' width='267' height='200' id='main' name='main'></td>
<td align='center' valign='top'><table width='100' height='188' border='1' cellpadding='2' cellspacing='0' bordercolor='#333333'>
<tr>
<td width='125' align='right'>";
echo "<a href=# onClick=forsalecntrl('$valuesїimg1]')><img src='images/forsale/thumbs/$valuesїimg1]' width='50' height='50'></a>";
echo "</td>
<td width='125' align='right'><img src='images/forsale/thumbs/$valuesїimg2]' width='50' height='50'></td>
</tr>
<tr>
<td height='46' align='right'><a href='#' onClick='imgcntrl('images/forsale/$valuesїimg3]', '1');'>
<img src='images/forsale/thumbs/$valuesїimg3]' width='50' height='50'></a></td>
<td align='right'><a href='#' onClick='imgcntrl('images/forsale/$valuesїimg4]', '1');'>
<img src='images/forsale/thumbs/$valuesїimg4]' width='50' height='50'></a></td>
</tr>
<tr>
<td align='right'><a href='#' onClick='imgcntrl('images/forsale/$valuesїimg5]', '1');'><img src='images/forsale/thumbs/$valuesїimg5]' width='50' height='50'></a></td>
<td align='right'><a href='#' onClick='imgcntrl('images/forsale/$valuesїimg6]', '1');'><img src='images/forsale/thumbs/$valuesїimg6]' width='50' height='50'></a></td>
</tr>
</table>
<br></td>
<td><div align='center' valign='top'>Description:<br>$descformat</div></td>
</tr>
</table><hr width='700' noshade class='intro'>Thanks,
TheDro