When I click on the contact us link it goes to this page:http://www.creativeplayer.net/store.php?page=contact
but the page is blank.
How do I get the store info from the database to come up in this link?
www.creativeplayer.net/store.php
When I click on the contact us link it goes to this page:http://www.creativeplayer.net/store.php?page=contact
but the page is blank.
How do I get the store info from the database to come up in this link?
www.creativeplayer.net/store.php
Hi Bryan,
Just so you know, the little Main Menu nav box has been disabled by default in more recent releases. It was there as more of a demonstration, than anything else. You can certainly use it. Please keep that in mind though. It is based on some functionality which hasn't been fully documented. Judging by the fact that you figured out how to add other links into it, then you can probably handle this.
OK... this will probably require a little PHP knowledge here...I'm going to attempt to explain how to do this via a customization:
1. First thing you need to know (if you don't already)is PHP is enclosed in <? ?> brackets. You can put regular HTML code anywhere outside of those brackets in a file named *.php, and PHP will parse ONLY the info between those brackets, and spit back the whole thing to your browser.
2. OK... first thing we need to handle is how to make different content come up when someone clicks that link. Here is an example of how you can do it via the demo.php file that comes with the cart:
In the code above, look at the section that says "customization here". This will include a file in your web root called contact.php when that link is clicked.PHP Code:<? include "/PATH/TO/YOURSERVERS/WEB/ROOT/squirrelcart/config.php";?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Squirrelcart Demo Store</title>
<? stylesheet("store.css"); ?>
<? stylesheet("extra.css"); ?>
</head>
<BODY>
<div align="center">
<br>
<table width="779" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" width="150">
<? eval(content_container("Store Navigation"))?>
</td>
<td width="619" valign="top">
<div class="content">
<?
if ($REQUEST_URI == "$cart_page" || $REQUEST_URI == "/") {
include "home.php";
$action = "show_cats_detail";
}
// customization here
if ($page=="contact") include "contact.php";
// end of customization
include "$cart_isp_root/cart_content.php";
?>
</div>
</td>
<td valign="top">
<? include "$cart_isp_root/product_preview.php" ?>
</td>
</tr>
</table>
</div>
</BODY>
</HTML>
3. OK...so know you should be able to make that file, throw some text in there, and test the link. It should display whatever is in that file.
4. Now...you need to get the store info from the DB into that file somehow. Something similar to this should do it (the functions are ones I created to talk to the DB):
What I would suggest is to see how far you get with this. If this works for you, you are probably going to ask how to get the state and country to not show up as a number! If you have that problem, please reply, and I will let you know how. I don't want to complicate this anymore, so I figured I would leave that out for now.PHP Code:<!-- top of your contact.php file -->
<?
$store_info = get_records("Store_Information","*","record_number = '1'");
$store_info = $store_info[0];
?>
<!-- now you can put HTML wherever you want here, and can get the info from the store as shown below -->
<font size="10pt">
<?=$store_info['Company_Name']?> has been in business for 25 years. We knock the socks off the competition. We are located at:<br>
<?=$store_info['Street']?> in beautiful downtown <?=$store_info['City']?>
</font>
blah blah blah
-Jamie
Thanks! I figured I would need to do in include statement. Just was not sure if I was missing something. I have a hard time following OO programming. I am learning php the hard way, on my own with no prevous programming experience. I use includes all the time but I do not have a handle on C++ type OO coding yet :?
No problem! Glad to help. If you ever have any questions, I am always willing to geek out! :idea:
BTW - I'm going to move this post into the Tutorials section. I think it would fit better there, as it is more of a how to, now that I put all that code in there. 8)
Could you use this same example to create any kind of page that pulls information out of the database; a different table perhaps
Yes, you could use that code to grab any data in the DB. BTW - the example code above was very messed up, but I just fixed it. It was written before we did our last forum conversion, and all the < > and " characters were replaced by HTML equivalents. It should look much better now.
The print_r function would be useful as well. If you are unsure of the structure of an array, you can use it to print it in it's entirety, like this:
print_r($store_info);
Thanks,
Jamie
Thanks for responding so quickly. I tried this and it worked. It is, however, not exactly the result that I am looking for. The above code gives me only the first record in the table. I need it to list all the records in that table. This is the code that I used as suggested above....
<?
$links = get_records("Links_t","*","record_number = '1'");
$links = $links[0];
?>
I added a new table to my dbase and now i am trying to integrate it into the cart. I was successful gettting it to load, but now I need the rest of the data to display.
You are very close. I only needed the 1st record in the example, so I grabbed only that one. To loop through them all, do this:
-JamiePHP Code:<?
$links = get_records("Links_t","*","record_number = '1'");
foreach($links as $link) {
print "Name: $link[Name]<br>";
print "URL: $link[URL]<br><br>";
}
?>
Thanks again for the reply. I feel like i'm really close to getting it. I used the above code and got only the first result again. Below is the enitre code maybe i am doing something wrong. I just upload the code and tried that and still only got the first record. Then I had to change it a little to accomadate the format that i wanted and still only the first record shows.
<html>
<body>
<?
$links = get_records("Links_t","*","record_number = '1'");
?>
<br>
<img src=images/linkshead.gif><br>
<font face="Arial, Helvetica, sans-serif" size="2"><br>
Welcome to the Links Section of our site. These links represent some of our favorite
places on the web as well as excellent sources of information. Take an opportunity
to check out these links. Have an idea for a link? Drop us a line at <a href="mailto:info@mikemunnsautographs.com">info@mi kemunnsautographs.com</a>
and we'll check out your suggestions. <br>
<br>
</font>
<table width="98%" border="0" cellpadding="4">
<tr bgcolor="#cccc99">
<td width="21%"><b><font size="1" face="Arial, Helvetica, sans-serif">Link</font></b></td>
<td width="79%"><b><font size="1" face="Arial, Helvetica, sans-serif">Description</font></b></td>
</tr>
<tr>
<?
foreach($links as $link) {
echo "<td width=21%><font size=1 face=arial><a href=http://$link[Links]>$link[Links]</a></td>";
echo "<td width=21%><font size=1 face=arial>$link[Description]</td>";
}
?>
</tr>
</table>
</body>
</html>
Thanks again in advance for your help
You can disregard the last post because I was able to figure it. Here is the solution I came up with it might be useful for some one else...
I changed....
<?
$links = get_records("Links_t","*","record_number = '1'");
?>
To This....
<?
$links = get_records("Links_t");
?>
this worked great now all I have to do is fugure out out to get them to sort. any idea you might have would be greatful. Thanks
Here is the function info....
function get_records($table,$select,$where=0,$sortby=0,$ord er=0,$test=0,$limit=0,$hide_records=0)
// $table is table to get records from
// $sortby is equal to a string of the name of the field you would like to sort by - ie "Name"
// $order is the order you want to sort in and can be either (0 or "ASC") for "ASC" or (1 or "DESC") for "DESC"
// $hide_records is used by functions that should not display hidden records. set it to 1 to hide records that are set as hidden in Record_Definition table
You would just need to do something like this:
Thanks,PHP Code:<?
$links = get_records("Links_t","*",0,"Name","ASC");
?>
Jamie
I need to call the data of warehouse inventory so sales associates can see what is available at any given time how do I get just the items inventory number , name, and inventory available?
Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)