BHB Posted October 19, 2011 Share Posted October 19, 2011 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 More sharing options...
BHB Posted October 19, 2011 Author Share Posted October 19, 2011 hmm,.. MYSQLI_NUM predefined constant. I've been looking at this for a long time and guess I had to finally make a public help request to see it. Shame. Sorry. Link to comment Share on other sites More sharing options...
Larry Posted October 19, 2011 Share Posted October 19, 2011 If you're new to PHP, you should not be reading the "PHP 5 Advanced" book. That book assumes sound knowledge of PHP (and MySQL). Are you really using this book or did you perhaps post in the wrong forum? Link to comment Share on other sites More sharing options...
Jonathon Posted October 19, 2011 Share Posted October 19, 2011 The code posted does match that in the Advanced book (As i'm sure you know) Link to comment Share on other sites More sharing options...
Larry Posted October 19, 2011 Share Posted October 19, 2011 Thanks, Jonathon. I actually don't have the book in front of me, so I wasn't sure. Link to comment Share on other sites More sharing options...
BHB Posted October 19, 2011 Author Share Posted October 19, 2011 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 More sharing options...
Larry Posted October 19, 2011 Share Posted October 19, 2011 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 More sharing options...
BHB Posted October 20, 2011 Author Share Posted October 20, 2011 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 More sharing options...
BHB Posted October 20, 2011 Author Share Posted October 20, 2011 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 More sharing options...
BHB Posted October 22, 2011 Author Share Posted October 22, 2011 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 More sharing options...
Jonathon Posted October 22, 2011 Share Posted October 22, 2011 I don't know what you mean. What code are you running? Do you get an error? Link to comment Share on other sites More sharing options...
BHB Posted October 23, 2011 Author Share Posted October 23, 2011 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 More sharing options...
BHB Posted October 24, 2011 Author Share Posted October 24, 2011 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 More sharing options...
BHB Posted October 25, 2011 Author Share Posted October 25, 2011 I'm guessing this is a problem in logic. I need to add the image filename/field to the price table and have a default image to hold the position until I load one. Link to comment Share on other sites More sharing options...
Larry Posted October 26, 2011 Share Posted October 26, 2011 It'd really be best if you created a new thread when you've moved on to a new problem. If you're still having problems with this, please start a new thread in the most appropriate forum. Link to comment Share on other sites More sharing options...
Recommended Posts