Jump to content
Larry Ullman's Book Forums

Define Variable Page 192, Line 45-48


Recommended Posts

I am a newbie to PHP. Larry is probably too busy to answer this simple question so I appreciate anyone's help.

 

I can not follow how 'fcat' and 'fcid' are defined in this header script. In database field name is 'category_id' and 'category'; I can see that category_id becomes fcid and understand adding 'f' to not complicate other queries further down the road. I just don't see where association was made... and it's right here in front of me I am sure.

 

thanks

BHB

Link to comment
Share on other sites

I did match the ISBN number,.. but sorry to bother everyone. I am crash coursing myself in just last few months. I've actually got 6 of your books Larry and just found the explanation for mysqli instead of mysql in one of the other books. I'm just anxious to get to what I need to do practically and your widget example is very suitable as an example. I'll refrain from asking stupid questions and just keep reading. :)

 

BHB

Link to comment
Share on other sites

First of all, thanks for the interest in my books. It is appreciated. Second, questions of any kind are certainly welcome here. All that being said, this particular book really is for people already thoroughly comfortable with the fundamentals of PHP. I just don't want you making the learning process harder on yourself.

Link to comment
Share on other sites

I learn best by difficult challenges and so your books/language and manner makes this very easy for me attempt difficult, figuring out the small details as I get scripts to work. So, I got it working your version and mine... except in mine I have referenced a table built on foreign keys with design view of PHPmyadmin. I want multiple categories per item (paintings in my case; will have many colors per painting) and I get the reference ID to show rather than the name. Using the designer in PHPmyadmin allows for easier entry of long names; prevent misspelling using drop down value list; not using SQL command line to enter. I think I just need to study the code a little longer and I'll see it. Maybe use a join rather.

 

PS I am having a blast! I dream looking for solutions.

Link to comment
Share on other sites

doing the happy dance!!!!

 

$q = "SELECT m.mult_id, m.painting_id, p.title

FROM multiple_categories AS m, paintings AS p

WHERE m.painting_id=p.painting_id

AND category_id=$cid";

$r = mysqli_query($dbc, $q);

 

if (mysqli_num_rows($r) > 1) {

 

// Print each:

while (list($mult_id, $painting_id, $title) = mysqli_fetch_array($r, MYSQLI_NUM)) {

 

// Link to the product.php page:

echo "<h2><a href=\"product.php?mult_id=$mult_id\">$title</a></h2>\n";

Link to comment
Share on other sites

ok, I hope this is not a stupid question. I am adding thumbnails using a folder for iamges, not the database. I have a table in database for image_name relating to painting_id. I figure this way I can have one folder for thumbs and another folder for full size images; everything presized into folders names the same. No PHP manipulation for image size necc.

 

I can call the images/thumbs from the folder in two separate queries; but then images grouped at top and list grouped below. When I attempt to call together with painting name, link etc and say I have not yet entered an image it becomes 'angry' and does not list the titles/links of paintings entered. Query does not complete with empty field relation. I've learned a lot in last day and happy to be this far so fast... just if anyone has a thought that is obvious I appreciate it. I feel like I know the answer just can't get it off the tip of my brain.

Link to comment
Share on other sites

no, no error. I got images to show up using database to call by filename but images are stored in a folder rather than in database. I just want my thumbnail to show along with the LIST info in code above. Trying one more thing,.. maybe I can figure it out.

Link to comment
Share on other sites

grrerror 'page accessed in error' message:

 

// Get the painting list in this category:

$q = "SELECT m.mult_id, m.painting_id, p.title, p.description_painting, i.image_name

FROM multiple_categories AS m, paintings AS p, images AS i

WHERE m.painting_id=p.painting_id

WHERE m.painting_id=i.painting_id

AND category_id=$cid";

$r = mysqli_query($dbc, $q);

 

if (mysqli_num_rows($r) >= 1) {

 

// Print each:

while (list($mult_id, $painting_id, $title, $p_description, $image) = mysqli_fetch_array($r, MYSQLI_NUM)) {

 

// Link to the product.php page:

echo "<img src=./eithumbs/$image><h2><a href=\"productC.php?mult_id=$mult_id\">$title</a></h2><p>$p_description\n";

 

} // End of while loop.

 

} else { // No widgets here!

echo '<p class="error">There are no paintings in this category.</p>';

}

 

} else { // Invalid $_GET['cid']!

echo '<p class="error">This page has been accessed in error.</p>';

}

Link to comment
Share on other sites

 Share

×
×
  • Create New...