dynamic image url

images php coding issues or problems here.

Moderators: macek, egami, gesf

007
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Feb 11, 2005 1:25 am
Location: Nakuru, Kenya
Contact:

dynamic image url

Postby 007 » Wed Mar 09, 2005 10:22 pm

I got a database thats full of penpall details and their photos for our school.

If someone searches the database, he gets several results. I want the penpall details to match their .jpg photos. So I have named the photos the corresponding penpall_ID.

What is wrong with this?

<table border=1 width=600>
<tr><td rowspan=8><? "<img src="http://127.0.0.1/penpalls/" . $row['penpall_ID'] . ".jpg">" ?>
</td></tr>
</table>

The images are in a different folder named 'penpalls'. Is this the best way to manage my photos.

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Re: dynamic image url

Postby ruturajv » Thu Mar 10, 2005 12:18 am

007 wrote:I got a database thats full of penpall details and their photos for our school.

If someone searches the database, he gets several results. I want the penpall details to match their .jpg photos. So I have named the photos the corresponding penpall_ID.

What is wrong with this?

<table border=1 width=600>
<tr><td rowspan=8><? "<img src="http://127.0.0.1/penpalls/" . $row['penpall_ID'] . ".jpg">" ?>
</td></tr>
</table>

The images are in a different folder named 'penpalls'. Is this the best way to manage my photos.


it should be

Code: Select all

<table border=1 width=600>
<tr><td rowspan=8><img src="http://127.0.0.1/penpalls/<? echo {$row['penpall_ID']};?>.jpg" />
</td></tr>
</table>

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Thu Mar 10, 2005 11:07 am

Also, just so you know, penpal is spelled with one L, not two.

007
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Feb 11, 2005 1:25 am
Location: Nakuru, Kenya
Contact:

Postby 007 » Fri Mar 11, 2005 6:25 am

Thanks. It however still gives me this error.

Parse error: parse error, expecting `','' or `';'' in c:\apache\htdocs\penpal\search.php on line 120

007
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Feb 11, 2005 1:25 am
Location: Nakuru, Kenya
Contact:

should I give the whole code?

Postby 007 » Fri Mar 11, 2005 6:39 am

Or should I give the whole code?

_______________________

<html>
<head>
<title>Penpals</title>
</head>
<body>
<font face="verdana" size=1 color="purple">
<h4>Penpal Search</h4>

<?php

if (!$_REQUEST) {
html_form();
} else {
select_penpal();
}

function html_form() {

?>

<table>
<tr><td><font size=1><b>
<form name="search" method="post" action="<? echo $_SERVER; ?>">
Type of Penpal:</td><td> <select name="type">
<option>All
<option>female
<option>male
<option>Other
</select></td></tr>
<tr><td><font size=1><b>
Location:</td><td><select name="province">

<option>All
<option>Nairobi
<option>R-Valley
<option>Coast
<option>Central
<option>Eastern
<option>Nyanza
<option>Western
<option>North-Estern
<option>Uganda
<option>Tanzania
</select><br>
</td></tr><tr><td></td><td>
<input type="submit" name="Submit" value="Search">
</td></tr>
</form>
</table>
<?

}


function select_penpal() {
?>
<h4>Search Results</h4>
<?

/* set's the variables for MySQL connection */

$server = "127.0.0.1"; // this is the server address

/* $username = "username"; // change this to your username
$password = "password"; // change this to your password */

/* Connects to the MySQL server */

$link = @mysql_connect ($server)
or die (mysql_error());

/* Defines the Active Database for the Connection */

if (!@mysql_select_db("penpal", $link)) {
echo "<p>There has been an error. This is the error message:</p>";
echo "<p><strong>" . mysql_error() . "</strong></p>";
echo "Please Contact Your Systems Administrator with the details";
}

/* Sets the SQL Query */

if($_POST == All && $_POST == All)
{
$sql = "SELECT * FROM penpal";
}
else
if($_POST == All)
{
$sql = "SELECT * FROM penpal";
$sql .= " WHERE (penpal.province = '{$_POST}')";
}
else
if($_POST == All)
{
$sql = "SELECT * FROM penpal";
$sql .= " WHERE (penpal.type = '{$_POST}')";
}
else
if($_POST == $_POST && $_POST == $_POST)
{
$sql = "SELECT * FROM penpal";
$sql .= " WHERE (penpal.type = '{$_POST}' AND penpal.province= '{$_POST}')";
}

/* Passes a Query to the active database*/

$result = mysql_query($sql, $link);
if(!$result)
{
echo("<p>Error perfoming query: " . mysql_error() . "</p>");
exit();
}

/* Starts the table and creates headings */

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>

<table border=1 width=600>
<tr><td rowspan=8> ><img src="http://127.0.0.1/penpal/<;? echo {$row};?>.jpg" />
</td><td><strong><font face="verdana" size=1 color="purple"> Penpal_ID</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td></tr>"); ?>
<tr><td><strong><font face="verdana" size=1 color="purple">Type</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td></tr>"); ?>
<tr><td><strong><font face="verdana" size=1 color="purple">Details</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td></tr>"); ?>
<tr><td><strong><font face="verdana" size=1 color="purple">Country</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td></tr>"); ?>
<tr><td><strong><font face="verdana" size=1 color="purple">Province</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td></tr>"); ?>
<tr><td><strong><font face="verdana" size=1 color="purple">District</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td></tr>"); ?>
<tr><td><strong><font face="verdana" size=1 color="purple">Other Details</strong></td><? echo("<td><b><font face=verdana size=1 color=black>" . $row . "</td>\n</tr>\n\n"); ?>
<br>

<br>
<?

/* Retrieves the rows from the query result set
and puts them into a HTML table row
*/
}
/* Closes the table */
?>
</table>
<br>
<br>
Search Again:
<?
/* Closes Connection to the MySQL server */

mysql_close ($link);

/* Displays HTML Form */
html_form();
}
?>


</body>
</html>
_______________________________

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

Postby ruturajv » Sun Mar 13, 2005 7:46 pm

Code: Select all

<tr><td rowspan=8> ><img src="http://127.0.0.1/penpal/<;? echo {$row};?>.jpg" />

should be

Code: Select all

<tr><td rowspan=8> ><img src="http://127.0.0.1/penpal/<?php echo $row; ?>.jpg" />


Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 1 guest

cron