Forum Moderators: coopster
ill go get the original post for you.
ill go get the original post for you.
i have the begining of what i need which is this...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
background-color: #000000;
}
body,td,th {
color: #9900FF;
}
-->
</style>
<div align="center">
<?php
$con = mysql_connect("mysql#*$!#*$!#*$!#*$!#*$!", "#*$!#*$!#*$!#*$!", "#*$!#*$!#*$!x");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("#*$!#*$!#*$!", $con);
$result = mysql_query("SELECT * FROM geri ORDER BY cd");
while($row = mysql_fetch_array($result)){
echo $row['cd'];
echo "<br />";
}
mysql_close($con);
?></head>
<body>
<div align="center"><tr><td><img src="<?= $row[cd] ?>"></td></tr></div>
</body>
</html>
i left in the echo $row['cd']; line just to check that im getting the right information back from the database and thats fine.
it adds a blank image box though instead of an image.
and i want to see all images in a row underneath each other in the site.
cant seem to figure that bit out yet.
the image name in the database should be all i need to show the image surely?
ive submitted the full path and the local path but i still get a blank image placed on screen.
heres what im getting when i goto the page... <snip>
ive had a few suggestions from someone but i still cant get it to work.
the images are all the same size and will fit into a table down the middle of the site.
hope someone can help
jeff
<?php
$con = mysql_connect("mysql#*$!#*$!#*$!#*$!#*$!", "#*$!#*$!#*$!#*$!", "#*$!#*$!#*$!x");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("#*$!#*$!#*$!", $con);
$result = mysql_query("SELECT * FROM geri ORDER BY cd");
while($row = mysql_fetch_array($result)){
$x = $row['cd'];
print "<table width=\"100%\" border=\"0\">
<tr>
<td align=\"center\"><img src=\"$x\"></td>
</tr>
</table>";
}
mysql_close($con);
?>
If the images dont show up, right click on the place holder where they should be and click properties and look at the path, see if it does point to the actual image
Your table bits were after everything has finished which would have only printed the last rows data.
$x = $row['cd'];
print "<table width=\"100%\" border=\"0\">
<tr>
<td align=\"center\"><img src=\"$x\"></td>
</tr>
</table>";
The above lays out each row (image) in its own table, you could get a bit fancier and print the opening table bits before the loop and each <td> during the loop then close the table afterwards.
First thoughts though, if I understand your question, would be category links (buttons or text) passing a variable to a template page
<a href=template.php?category=$x>Visit Category X</a>
and use the same variable in your MySql statement to select data from that category
select * from table where column=$x
Is that what you are looking for
do i add the link back to the page itself?
and can i add select *from geri where column=$x order by $x ?
as i need to alphabetise the images before adding them to teh page.
if you could point me in teh right direction as to which bits to change...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SPICE GIRLS COLLECTION ... THIS IS MY COLLECTION OF MEMORABILIA.</title>
<style type="text/css">
<!--
body,td,th {
color: #000000;
}
body {
background-color: #DC718F;
}
.style2 {color: #FFFFFF}
.style3 {font-size: 12px}
-->
</style></head>
<body>
<table width="900" border="0" align="center" bgcolor="#FFFFFF">
<tr>
<td><p align="center"><?php
require("topbanner.php")
?> </td>
</tr>
<tr>
<td><p align="center"><?php
require("topmenu.php")
?> </td>
</tr>
<tr>
<td><table width="900" height="700" border="0">
<tr>
<td width="170" height="2"> </td>
<td width="550" height="2"> </td>
<td width="170" height="2"> </td>
</tr>
<tr>
<td width="170" height="700" align="center" valign="top" bgcolor="#FFFFFF"><div align="left">
<table width="170" height="700" border="0" background="images/COLLECTION CDS/WEBSIDEBANNER600.jpg">
<tr>
<td height="220"> </td>
</tr>
<tr>
<td height="40"><div align="center">
<h3 class="style2"><strong>CATEGORY</strong></h3>
</div></td>
</tr>
<tr>
<td height="400" valign="top"><div align="center">
<p> </p>
<p><a href="#">spice girls</a></p>
<p><a href="#">geri</a></p>
</div>
<p align="center"><a href="#">victoria</a></p>
<p align="center"><a href="#">emma</a></p>
<p align="center"><a href="#">mel b</a></p>
<p align="center"><a href="#">mel c</a></p></td>
</tr>
</table>
</div></td>
<td width="550" valign="top"><div align="center">
<h2>WELCOME TO MY COLLECTION PAGES</h2>
<p class="style3"><strong>FIRST SELECT THE BAND OR BAND MEMBER YOU WANT</strong></p>
<p class="style3"><strong>TO VIEW ITEMS OF.</strong></p>
<p class="style3"><strong>THEN CLICK ON THE ITEM CATEGORY ON THE RIGHT </strong></p>
<p class="style3"><strong>TO VIEW THE ITEMS </strong></p>
<p class="style3"> </p>
<table width="500" border="0" align="center">
<tr>
<td><div align="center"><?php
$con = mysql_connect("mysql#*$!#*$!#*$!#*$!#*$!x", "#*$!#*$!#*$!x", "#*$!#*$!#*$!#*$!x");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("#*$!#*$!#*$!#*$!xx", $con);
$result = mysql_query("SELECT * FROM geri ORDER BY cd");
while($row = mysql_fetch_array($result)){
$x = $row['cd'];
print "<table width=\"100%\" border=\"0\">
<tr>
<td align=\"center\"><img src=\"$x\"></td>
</tr>
</table>";
}
mysql_close($con);
?></div></td>
</tr>
</table>
<p class="style3"> </p>
<p class="style3"> </p>
<p class="style3"> </p>
</div>
<div align="center"></div>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p></td>
<td width="170" height="690" valign="top"><table width="170" height="700" border="0" background="images/COLLECTION CDS/WEBSIDEBANNER600.jpg">
<tr>
<td height="220"> </td>
</tr>
<tr>
<td height="40"><div align="center">
<h3 class="style2"><strong>CATEGORY</strong></h3>
</div></td>
</tr>
<tr>
<td height="400" valign="top"><div align="center">
<p> </p>
<p><a href="#">cd</a></p>
<p><a href="#">dvd</a></p>
<p><a href="#">video</a></p>
<p><a href="#">awards</a></p>
<p><a href="#">memorabilia</a></p>
<p><a href="#">clothing</a></p>
<p><a href="#">magazines</a></p>
<p><a href="#">jewellery</a></p>
<p><a href="#">autographs</a></p>
<p> </p>
</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td><div align="center">
<?php
require("bottombanner.php")
?>
</div></td>
</tr>
</table>
</body>
</html>
("SELECT * FROM geri ORDER BY cd")
As you (like me) seem newish to PHP the way I would work is seperate pages so the links would go to a results page which has its own sql function, hard code it first then change it to accept different NAMES.
Then move onto a page for categories, get it working how you want then if you want to run from one page work out how many if() else statements you will need to handle different sets of data ALL posabilities.
Your links to each singer or category, I would call them from the database and build the links for zero maintenance later ie
SELECT name FROM spice_girls ORDER BY DESC
then
$x = $row['name'];
print <a href="results.php?name=$x>$x</a>
which would produce
results.php?name=Geri">Geri</a
And Geri would be past to the results page so your sql statement would receive it like
SELECT * FROM spice_girls WHERE name ='$x'
Work on one page at a time, it'll keep your post lengths down too ;) HTH
trying to fathom that one now.
each database table has its own girls name and a spicegirls one seperate.
so i have 6 tables with 10 categories in.
this has been suggested
$search_option = "cd";
if ($_POST['search_for'] == "dvd") { $search_option = "dvd"; }
$sql = "SELECT ".$search_option." FROM victoria ORDER BY ".$search_option;
would i simply just add 10 lines of the if statement line changing the category in each one?
and would i do this at the top of my html page or actually where i need the images printing in my page?
would <a href=template.php?category=$x>cd </a> be my button html?
does anyone know any good books on this subject?
as i feel helpless and unarmed at some of the replies in here.
i appreciate teh time u guys are taking to try and help out though.
$name (which could hold Victoria)
OR
$name $dvd (which could hold Victoria and a DVD of hers)
if isset($_POST['name'] && !$_POST['dvd']) # only name
{
$sql = "SELECT * FROM $name";
}
if isset($_POST['name'] && $_POST['dvd']) # both
{
$sql = "SELECT dvd FROM $name";
}
$result = mysql_query($sql, $con) or die("error");
while ($row = mysql_fetch_array($result))
{
$x = $row['name'];
$y = $row['dvd'];
print "$x $y";
}
You should also have code in place to catch a page called to a browser empty, either using
header(Location:
OR
A default sql statement that loads content
If you gather your variables at the top of the page you can use them in your title and description tags too like this
<title><?PHP print $name?> is one of the girls</title>
Hope that helps a bit, I havent tested any of the code;)
i think i understand the logics of it but making them work is beyond me at the moment.
the nets not very helpful on these matters without using forums set up by people like yourselves,so thanks everyone who posts advice.