Need some feedback please on a project

Discuss all aspects of programming here.

Moderator: The Mod Squad

Postby Toby B. » Wed Jul 06, 2005 7:28 pm

Code: Select all
<?php
if ($add_images == None) {
   echo "None";
} else if ($add_images != None) {
   echo "<a href='".htmlentities($add_images)."'>$ai_descript</a>";
   }
?>


Appears to be working as coded like this.. Still need to run another test page to see though..
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Toby B. » Wed Jul 06, 2005 7:54 pm

3 different test pages completed and working fine.... :P

Happy as a pig in $%^!@# right now.... :D
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Toby B. » Mon Jul 11, 2005 4:27 pm

Another flaw in my code... :roll:

All links work fine if they are "internal" (meaning point to the ctechinfo website) and not "external" (meaning pointing to other websites such as motherboards.org). "External" links fall back to the directory index of whatever folder the page is in...

The other bit of code that I am not able to get right is for the images... I am wanting to create a code that when a page is viewed that has no corresponding motherboard image a "place holder" image (i.e. a "no image" pic) is displayed; and if a motherboard pic does exist the pic is show. But I need to code to be flexible in regaurds to the display size as there are some images that get distorted with the current standard height="125".
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby MoboCop » Wed Jul 13, 2005 1:06 pm

suggestion. Post a specific piece of code and tell me what it should do and what it is doing.

External links have to have full url with http://

To show a default image if another does not exist is fairly simple. I do it on home page and review indexes.

goes something like this.
Code: Select all
if(file_exists($file))
{
      show existing file code;
} else {
     show defualt image code;
}


reference php.net/file_exists for more info on this function. The tricky part on testing the file exists is the path. You have to include internal path whatever that may be so your file variable would look something like this

Code: Select all
$file = $_SERVER["DOCUMENT_ROOT"] . $path_to_file_from_root;


replace the path_to_file_from_root with your file to test.

as far as flexible for display size I have no comment until I can see a working example of this page and where the image is laid out.
Not everything that can be counted counts, and not everything that counts can be counted - Albert Einstien
MoboCop
Drunken Master
 
Posts: 8854
Joined: Tue Jan 18, 2000 1:01 am
Location: Fresno

Postby Toby B. » Wed Jul 13, 2005 1:31 pm

MoboCop wrote:To show a default image if another does not exist is fairly simple. I do it on home page and review indexes.

goes something like this.
Code: Select all
if(file_exists($file))
{
      show existing file code;
} else {
     show defualt image code;
}


reference php.net/file_exists for more info on this function. The tricky part on testing the file exists is the path. You have to include internal path whatever that may be so your file variable would look something like this

Code: Select all
$file = $_SERVER["DOCUMENT_ROOT"] . $path_to_file_from_root;


replace the path_to_file_from_root with your file to test.


on the file exists code example does it need the echo in there?
Code: Select all
if(file_exists($file))
{
   echo   "show existing file code";
} else {
   echo  "show defualt image code";
}


basically I have a bunch of borked code. Trying to use a book as a reference guide.
Code: Select all
<?php
if (file_exists($image != None)) {
   echo "'<a href='".htmlentities($image)." target="__new"'>'";
}
<img src="'<?php echo($image);?>" border="0" height="150"'></a>'";
} else ($image == None)) {
   echo "'<a href='"./../../common/noimage.jpg" target="__new"'>";
<img src="'./../../common/noimage.jpg" border="0" height="150"'></a>'";
}
?>


On the HTML pages I have them setup something like this:
Test page code:-
Code: Select all
<?php
/* File revision 7/04/05 @ 4:15AM:- There is an information link at the bottom or this page. PLEASE keep an eye on that thread and post as necessary in that thread!!! */
$meta_title = "Tahiti 2.x - HP OEM Asus A7V-VM Motherboard";
/* $meta_title is what found between the <title></title> */
$content1 = "Spec sheet and downloads for the HP Tahiti motherboard";
/* $content1 is the description portion of the meta tags */
$content2 = "HP, Tahiti 2.x, motherboard, spec sheet, downloads, information";
/* $content2 is the keywords portion of the meta tags */
$page_name = "Tahiti 2.x";
/* $page_name is what shows on the top of the pages NOT the title bar!! */
$image = "None";
/* $image is the code that controls the actual pic on the page. Not the actual size control but the location of the image. */
$processors = "Unknown";
/* $processors is the code that controls the listing for the processor for the board(s) */
$bus = "Unknown";
/* $bus is the code that controls the listing for the bus speed for the board(s) */
$chipset = "Unknown";
/* $chipset is the code that controls the listing for the chipset for the board(s) */
$RAM = "Unknown";
/* $RAM is the code that controls the listing for the RAM for the board(s) */
$video = "Unknown";
/* $video is the code that controls the listing for the Video for the board(s) */
$audio = "Unknown";
/* $audio is the code that controls the listing for the Audio for the board(s) */
$expansion = "Unknown";
/* $expansion is the code that controls the listing for the Expansion Slots for the board(s) */
$part_numbers = "Unknown";
/* $part_numbers is the code that controls the listing for the Spare Part Numbers for the board(s) */
$add_images = "None";
/* $add_images is the code that controls the listing for any additional image(s) such as Front Panel pinouts, etc.. */
$models = "<b>HP</b> - <i>7770(P3052A-ABU), 7830(P3077A-ABN), 7830(P3082A-ABE), 7840(P3066A-ABH),
7850(P3073A-ABS), 7860(P2881A-ABF), 7860(P3085A-ABE), 7861(P2997A-ABM),
7870(P2883A-ABF), 7880(P3061A-ABU), 7880(P3068A-ABH), 7880(P3074A-ABS),
7880(P3079A-ABN), 7890(P2887A-ABF), 7891(P3064A-ABU), 8705(D7205Y-ABA),
8705(D7206A-ABA), 8705(D7206B-ABA), 8705(D7206C-ABA), 8705(D7206D-ABA),
8705(D7206E-ABA), 8705(D7206F-ABA), 8705(D7206G-ABA), 8710(D7206W-ABA),
8710(D7206Y-ABA), 8720(D7206P-ABA), 8720(D7206Q-ABA), 8750(P2882A-ABS),
8760(P2885A-ABS), 8775(P2849A-ABU), 8776C(P2978A-ABA), 8860(P2941A-ABA),
8870(P2942A-ABA), 8890(P3128A-ARS), 9720(P2852A-ABU), 9725(P1433A-ABF),
9726(P2906A-ARS), 9726(P2906A-UUB), 9730(P2864A-ABF), 9740(P2854A-ABU),
T9715(P2862A-ABF), XL844(P3978A-ABA), XL847(P3980A-ABA), XL866(P3945A-ABA),
XL876(P3946A-ABA), 7835, 7865, 7885, FR 7939, UK 7940, US/CAN 7950, FR 7950, NL 7950, NW 7950, UK 7950, LA 7957, SP 7960, xL946 US/CAN, 9720 cfg-PC, AP 8886</i>";
/* $models is the code that controls what systems this board is found in. This particular test file pertains to a board that is only found/reported in HP systems. Please follow the link at the bottom of this page for more detailed information... */
$b_docs = "None";
/* $b_docs is the code that controls what manuals/documentation/etc is availible for this board. */
$retail = "This motherboard is an OEM Asus A7V-VM. <br><i>No retail information availible at this time.</i>";
/* $retail is the code that controls What the manufacturer and model of the board is. Please be sure to keep the code tags intact!! */
$notes = "HP";
/* $notes is what adjusts the Manufacturer in the notes section of each page. You will need to update this accordingly!! */
$f_link = "/forum/viewtopic.php?t=552";
/* $f_link represents the link to the Motherboard Pages Discussions thread */
include ('includes/header2.inc');
include ('includes/template1.tpl');
/* header2.inc is the code that contains the Title, META tags, and HEAD code. You need not worry about this file with the availible adjustments above.
   template1.tpl --->> See http://www.ctechinfo.org/forum/viewtopic.php?t=655 For more information..
 */
?>


In the test folder on the server I can get away with using "/path/to/file" but on the actual live pages I havent managed to get the code down pat enough to read the root directory so I have to use "./../../folder/file" (to link the includes and the .tpl file.

The location of the "No Image" pic is /common/noimage.jpg which is. Any pages that have pics for the board(s) have the corresponding pic in that folder. Like say the ZZ-Top board is located in /model/zz-top/ both the page and image are located there so for the image I just post it like so: zz-top.jpg

hmm, I hope you can make heads or tails of this... :oops:
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Toby B. » Wed Jul 13, 2005 2:10 pm

Should I blow it up now or later? :cry: :roll: :cry:

Code: Select all
12 <?php
13 $file = "$_SERVER["DOCUMENT_ROOT"] . '$/common/noimage.jpg'";
14 if ($image == None) {
15   echo "$file";
16 } else if ($images != None) {
17   echo "<a href='".htmlentities($image)." target="_new"'>$<img
18  src='".htmlentities($image)." border="0" height="$size"'></a>";
19   }
20 ?>


Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /homepages/22/d87841612/htdocs/test/includes/template1.tpl on line 13
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby MoboCop » Wed Jul 13, 2005 4:16 pm

Code: Select all
13 $file = "$_SERVER["DOCUMENT_ROOT"] . '$/common/noimage.jpg'";


Toby you need to learn the basics of php still. Quotes(single or double) are for text only. You do not enclose variables in quotes. So dealing with that issue we are left with...

Code: Select all
13 $file = $_SERVER["DOCUMENT_ROOT"] . '$/common/noimage.jpg';


ok now we still have a problem. you have a path in single quotes that starts with a $ which is what is used for a vairiable. No knowing what we are trying to accomplish we need a variable here that we are testing for. The noimage path is not write. You need to have a varaible here that is different for each page that loads since that is the image we want to test for.

Code: Select all
13 $file = $_SERVER["DOCUMENT_ROOT"] . $current_image;


So in above code each page is going to provide a value to current_image variable to test if image exists.
Not everything that can be counted counts, and not everything that counts can be counted - Albert Einstien
MoboCop
Drunken Master
 
Posts: 8854
Joined: Tue Jan 18, 2000 1:01 am
Location: Fresno

Postby Toby B. » Wed Jul 13, 2005 4:21 pm

Toby you need to learn the basics of php still.


I am working on it... :lol: Might not look it but I am... :P

I came a bit close with a rewrite of some of the code, but then blew it up again...

Gotta go to work (i.e. the IRL job) for a few hours will be back with the code I almost had working...
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Toby B. » Wed Jul 13, 2005 6:12 pm

Probably quite bloated but I got it figured out enough to work... The Image code that is:
Code: Select all
<?php
$imgpath = "./../../common/noimage.jpg";
?>
<a href="<?php if ($image == None) {
   echo ($imgpath);
 
} else if ($image != None) {
   echo ($image);
   }
;?>" target="__new">
<img src="<?php if ($image == None) {
   echo ($imgpath);
 
} else if ($image != None) {
   echo ($image);
   }
;?>" border="0" height="<?php echo($size);?>">


The external links I am still working on...
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

Postby Toby B. » Wed Jul 13, 2005 8:05 pm

:mb_bangdesk::

Code: Select all
$rlink = 'http://www.intel.com/design/motherbd/oem/index.html'


I really need to learn to pace myself... :roll:

Code: Select all
<?php
if ($retail == None) {
   echo "There is no retail information availible.";
} else if ($rlink != None) {
   echo "<a href='".htmlentities($rlink)."'>$rlink</a>";
   }
if ($rlink2 != None)
   echo "<a href='".htmlentities($rlink2)."'>$rlink2_descript</a>";
?>


Havent tried to use 2 links at a time with the updated code, but I got the single links figured out... :oops:
Toby B.
Lead Mobo-fu Master
Lead Mobo-fu Master
 
Posts: 14277
Joined: Sun Dec 16, 2001 1:01 am
Location: Maine

PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron