Jump to content
MakeWebGames

adding images to your shops etc


Tangled

Recommended Posts

I'm sure [MENTION=65371]sniko[/MENTION] can help? :p

Joking.

Assuming you've already inserted the image in to the database you'd output the image using a while(); loop like normal and put it all in a table and the images is put next to the item.

Back when I was making a game I used the following code. Use it and adapt it to work in your situation.

while($res = $selectHangerInfo->fetch(PDO::FETCH_OBJ)) {
   $b64Src = "data:image/jpeg;base64," . base64_encode($res->Display_Image);
   echo '<tr><td style="float: left; text-align: left;"><img src="'.$b64Src.'" /></td>';   
   echo '<td><strong>Hanger Type: </strong>'.$res->Name.'<br/><strong>Cost: </strong>'.$selectCurrencyRes->Currency_Symbol.$functions->formatNumber($res->Cost).'<br/><strong>Construction Time: </strong>'.$res->Construction_Time_Minutes.' Minutes<br/><strong>Holding Capacity (Planes):</strong> '.$res->Plane_Holding.'</strong></td>';
   echo '<td><a href="index.php?module=hangerShop&hangerID='.$res->ID.'&buy=true">Buy '.$res->Name.'</a></td>';
   echo '</tr>';
}
Link to comment
Share on other sites

I'm sure [MENTION=65371]sniko[/MENTION] can help? :p

Joking.

Assuming you've already inserted the image in to the database you'd output the image using a while(); loop like normal and put it all in a table and the images is put next to the item.

Back when I was making a game I used the following code. Use it and adapt it to work in your situation.

while($res = $selectHangerInfo->fetch(PDO::FETCH_OBJ)) {
   $b64Src = "data:image/jpeg;base64," . base64_encode($res->Display_Image);
   echo '<tr><td style="float: left; text-align: left;"><img src="'.$b64Src.'" /></td>';   
   echo '<td><strong>Hanger Type: </strong>'.$res->Name.'<br/><strong>Cost: </strong>'.$selectCurrencyRes->Currency_Symbol.$functions->formatNumber($res->Cost).'<br/><strong>Construction Time: </strong>'.$res->Construction_Time_Minutes.' Minutes<br/><strong>Holding Capacity (Planes):</strong> '.$res->Plane_Holding.'</strong></td>';
   echo '<td><a href="index.php?module=hangerShop&hangerID='.$res->ID.'&buy=true">Buy '.$res->Name.'</a></td>';
   echo '</tr>';
}

lol there's no slot in the database for an image... I need help getting that in. that's where I started. sigh I know go study some more ....

Link to comment
Share on other sites

Depends on how you would want to do it and structure it, but usually images are placed under a special images directory you have in your file structure.

Then, in the database, you add a column to place the image file itself for your items (whatever it may happen to be called).

After that is done, the coding part is not too bad. Again, all depends on how you would want to do it. You can either create a function like I did to accomplish this:

 

show_image($image_file_name, $item_id);

 

and build a function in a classes file like so:

 

 function show_image($image, $id) {
return  "<a href='javascript:;' onclick=\"javascript:window.open( 'description.php?id=".$id."', '60', 'left = 20, top = 20, width = 400, height = 440, toolbar = 0, resizable = 0, scrollbars=0, location=0, menubar=0'  );\"><img src='".$image."' width='100' height='100' style='border: 1px solid #000000'></a>";
}

 

or you can do something like Script did. They all basically do something similar.

~G7470

Edited by G7470
Link to comment
Share on other sites

Depends on how you would want to do it and structure it, but usually images are placed under a special images directory you have in your file structure.

Then, in the database, you add a column to place the image file itself for your items (whatever it may happen to be called).\

After that is done, the coding part is not too bad. Again, all depends on how you would want to do it. You can either create a function like I did to accomplish this:

 

show_image($image_file_name, $item_id);

 

and build a function in a classes file like so:

 

 function show_image($image, $id) {
return  "<a href='javascript:;' onclick=\"javascript:window.open( 'description.php?id=".$id."', '60', 'left = 20, top = 20, width = 400, height = 440, toolbar = 0, resizable = 0, scrollbars=0, location=0, menubar=0'  );\"><img src='".$image."' width='100' height='100' style='border: 1px solid #000000'></a>";
}

 

or you can do something like Script did. They all basically do something similar.

~G7470

Thank you both for your imput and advice...I am such a noob I'm reading what script suggested. I am doing my best to learn how to do this haha dictionary time!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...