Hi, I'm trying to update a current pictures site from html into php with a mysql backend, im pretty new to php and mysql and have run into a problem I cant seem to remedy??, any help would be great!.
I have set up the database, and in the database I have 2 tables so far, one is for the pictures categories which has the names of the categories, and the urls, and the other is for the pictures which has the title of the pictures, and filenames and description, so I linked them both with a associated primary/foreign key relationship.
Now my problem is with a section on my site I would like the latest pictures posted to be shown, so I used a href so you can click on anyone and it will take you to that pictures category, the only problem is I get the latest pictures showing up fine, but when I put the mouse on them the url is the same all the way down, rather than change for each individual picture category, it stays the same link?, ive tried as much as I know so far, but still the same problems?, what can I do?.
PHP Code:
mysql_select_db($database, $connDB) OR DIE ('Unable To Select That Database' . mysql_error() );
$query_sPictures = "SELECT site_pictures.sp_filename_TN, site_pictures.sp_ALT FROM site_pictures ORDER BY site_pictures.sp_timestamp ASC";
$sPictures = @mysql_query($query_sPictures, $connDB) or die(mysql_error());
$row_sPictures = mysql_fetch_assoc($sPictures);
$totalRows_sPictures = mysql_num_rows($sPictures); <-- This part works fine
?>
<?php
$query_sCategories = "SELECT site_categories.sc_url FROM site_categories, site_pictures WHERE site_pictures.sc_id = site_categories.sc_id";
haha, i didn't even wanna think that much about it,
sort of hurts just to look at ;-P
but, practice makes perfect
Couldn't agree with you more, Angst. My intial response was directed to eDawg and didn't mean to seem like I was commenting on your suggestion.
eDawg,
As Angst suggested please try to clean up your code before just copying and pasting. This will help others when then attempt to look through your code to help.
Why not do something like this in lieu of the code you provided.
PHP Code:
<?php
$qry = "SELECT sp.sp_filename_TN, sp.sp_ALT, sc.sc_url FROM site_categories sc, site_pictures sp WHERE sp.sc_id = sc.sc_id ORDER BY sp.sp_timestamp ASC";
$rslt = @mysql_query($qry, $connDB) or die(mysql_error());
$total_rows = mysql_num_rows($rslt);
while ($row = mysql_fetch_assoc($rslt)){
echo "<a href=\"$row['sc_url']\"><img src=\"pictures/$row['sp_filename_TN']\" alt=\"$row['sp_ALT']\"></a>";
}
mysql_close($connDB);
?>
Hi, and thanks for your help!!!, I will clean up code in the future, because ill probably be in here alot.
I just tried the code you gave me, but get this error,
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in file/latest_pictures.php on line 6