Jump to content

Very New To Programming And Need Help


RobC73

Recommended Posts

I am trying to learn html and php, at the same time and I hope not to offend anyone but, I can't figure out why this link will not work as I'm trying to pull data from MySQL...please advise

 

<LI><A HREF="productcat.php?cat=Gas cards.$row['prodID']">Gas cards</A></LI>

 

The above link is in the html section but, I also use the same variable in the php section in which it works just fine...

 

or, have I answered my own question stating that html can not retrieve data from MySQL?

 

or, maybe there's a better way to write this?

Edited by RobC73
Link to comment
Share on other sites

I apologize for the 3 posts :(

 

here is the entire page:

 

<?php

session_start();

?>

<html>

<head>

<META http-equiv="Content-Style-Type" content="text/css">

<title>Pennybodycanwin - Products by Category</title>

 

<style type="text/css">

<!--

A:link {text-decoration: none; color: #000000}

A:visited {text-decoration: none; color: #000000}

A:active {text-decoration: none; color: #000000}

A:hover {text-decoration: underline}

LI {

margin-left: 0;

padding-left: 0;

line-height: 1em;

font-family: Verdana;

font-size: .8em;

}

H1 {

color: #0000FF;

font-family: Sans-Serif;

font-size: 1.10em;

font-weight: bold;

}

H2 {

font-family: Sans-Serif;

font-size: 1.20em;

line-height: .25em;

font-weight: bold;

}

P {

margin-left: 0;

padding-left: 0;

line-height: 1em;

font-family: Verdana;

font-size: .9em;

text-align: justify;

}

}

-->

</style>

<!-- H1 is ptitle H2 is pprice P is pdesc -->

 

</head>

<body bgcolor="#FFEFD5" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>

 

 

<table width="100%" cellpadding="0" cellspacing="0" border="0">

 

<tr>

<td height="30" bgcolor="#FFEFD5" colspan="3"><font face="Arial" color="#000fff"><b><center>What is pennybodycanwin?   Learn more and <a href="../about.html"><font color="#000000"><u>register</u></font></a> here</center></b></font></td>

</tr>

 

<tr>

<td>

<table cellpadding="0" cellspacing="0" border="0" width="100%">

<tr>

<td height="70" width="500" bgcolor="#FFEFD5"><a href='index2.php'><img src="_img/Pennybodycptshinerfont.jpg" border="0"></a></td>

 

<td align="right" valign="top"> </td>

<td width="100">

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">

<input type="hidden" name="cmd" value="_s-xclick">

<input type="hidden" name="hosted_button_id" value="SLWUTYSJ7JB86">

<input type="image" src="https://www.paypalob...donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">

<img alt="" border="0" src="https://www.paypalob...i/scr/pixel.gif" width="1" height="1">

</form>

</td>

</tr>

</table>

</td>

</tr>

 

<tr>

<td height="100" width="340" background="_img/pennybar.jpg">

<table width="340" height="100" cellpadding="0" cellspacing="0" border="0">

<tr height="62"><td colspan="3"> </td></tr>

<tr height="30"><td>

<table width="440" height="30" cellpadding="0" cellspacing="0" border="0" background="_img/tabs_home.jpg">

<tr>

<td><a href='index2.php'><center><img src='../_img/blnk_btn.png' border='0' width="105"></center></a></td>

<td><a href='../about.html'><center><img src='../_img/blnk_btn.png' border='0' width="105"></center></a></td>

<td><a href='../register.html'><center><img src='../_img/blnk_btn.png' border='0' width="105"></center></a></td>

<td><a href='../howitworks.html'><center><img src='../_img/blnk_btn.png' border='0' width="105"></center></a></td>

</tr>

</table>

</td>

</tr>

<tr height="*"><td colspan="3"> </td></tr>

</table>

</td>

<td height="100" width="*" background="_img/pennybar.jpg"> </td>

</tr>

 

 

<!---------------------- MAIN BODY ----------------------->

<tr>

<td bgcolor="#ffffff">

 

<table width="100%" cellpadding="10" cellspacing="0" border="0" bgcolor="#FFEFD5">

<tr>

<td width="200" valign="top"><b>Categories</b>

<ul>

<LI><A HREF="productcat.php?cat=Gas cards">Gas cards</A></LI>

<LI><A HREF="productcat.php?cat=Gift cards">Gift cards</A></LI>

<LI><A HREF="productcat.php?cat=Food"><font color="blue">Food</font></A></LI>

<LI><A HREF="productcat.php?cat=Cars">Cars</A></LI>

<LI><A HREF="productcat.php?cat=TVs">TVs</A></LI>

<LI><A HREF="productcat.php?cat=Computers">Computers</A></LI>

<LI><A HREF="productcat.php?cat=E-Readers">E-Readers</A></LI>

<LI><A HREF="productcat.php?cat=Cameras">Cameras</A></LI>

<LI><A HREF="productcat.php?cat=Video Consoles/Games">Video Consoles/Games</A></LI>

<LI><A HREF="productcat.php?cat=Cash">Cash</A></LI>

<LI><A HREF="productcat.php?cat=Washer and Dryer">Washer and Dryer</A></LI>

<LI><A HREF="productcat.php?cat=Refrigerator">Refrigerator</A></LI>

<LI><A HREF="productcat.php?cat=Small Appliances">Small Appliances</A></LI>

<LI><A HREF="productcat.php?cat=Cookware">Cookware</A></LI>

<LI><A HREF="productcat.php?cat=Bedding">Bedding</A></LI>

<LI><A HREF="productcat.php?cat=Furniture">Furniture</A></LI>

<LI><A HREF="productcat.php?cat=Tools">Tools</A></LI>

<LI><A HREF="productcat.php?cat=Toys">Toys</A></LI>

<LI><A HREF="productcat.php?cat=Cruises">Cruises</A></LI>

</ul>

</td>

 

<td width="100%">

 

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<?php

$custid = $_GET['custid'];

echo "Got it!";

include("../cgi/rit_cxn.php");

$cxn = mysqli_connect($hostname,$username,$password,$dbname) OR DIE ('Unable to connect to database! Please try again later.');

$pcat = $_GET['cat'];

 

$query = "SELECT * FROM $usertable WHERE category = '$pcat'";

$result = mysqli_query($cxn,$query);

$num_rows = mysqli_num_rows($result);

echo "<tr>\n";

 

while($row = mysqli_fetch_assoc($result))

{

$ptble = 'product' . $row['prodID'];

$ptrows = mysqli_query($cxn,"SELECT * FROM $ptble WHERE pbal='1'");

if (mysqli_num_rows($ptrows)==0){

$blnce = 0;

}

else {

$blnce = mysqli_num_rows($ptrows) * .01;

}

$bidlink = 'prodbid.php?pid=' . $row['prodID'] . '&custid=' . $custid;

 

$cnt_itms = $cnt_itms + 1;

echo " <td><center>\n";

echo " <table width='400' height='400' cellpadding='0' cellspacing='0' border='3' bgcolor=CD853F>\n";

echo " <tr>\n";

echo " <td>\n";

echo " <table cellpadding='0' cellspacing='0' border='0' width='200' height='380'>\n";

echo " <tr>\n";

echo " <td width='200' height='200'><img src='../_img/{$row['ppic']}' height='150' width='180'></td>\n";

echo " </tr>\n";

echo " <tr height='80'>\n";

echo " <td valign='top'><font size='2'>Item #: {$row['prodID']}</font><br><br><center>Your price:<br><H2>${$row['pprice']}</H2></center></td>\n";

echo " </tr>\n";

echo " <tr height='100'>\n";

echo " <td><center><a href='$bidlink'><img src='../_img/donate_btn.png' border='0'></a></center></td>\n";

echo " </tr>\n";

echo " </table>\n";

echo " </td>\n";

echo " <td>\n";

echo " <table cellpadding='5' cellspacing='10' border='0' width='200' height='380'>\n";

echo " <tr>\n";

echo " <td colspan='3' height='30' width='200' valign='top'><H1>{$row['ptitle']}</H1><td>\n";

echo " </tr>\n";

echo " <tr>\n";

echo " <td colspan='3' valign='top'><P>{$row['pdesc']}</P></td>\n";

echo " </tr>\n";

echo " <tr>\n";

echo " <td width='25'> </td>\n";

echo " <td height='130' background='../_img/pbank.png' style='background-repeat:no-repeat;'><center>\n";

echo " <table cellpadding='0' cellspacing='0' border='0' width='90' height='20'>\n";

echo " <tr>\n";

echo " <td bgcolor='#FFFF00' valign='middle'><center><font size='4'>$blnce<font></center></td>\n";

echo " </tr>\n";

echo " </table>\n";

echo " </center></td>\n";

//echo " <td width='25'> </td>\n";

echo " </tr>\n";

echo " </table>\n";

echo " </table>\n";

echo " </center></td>\n";

if ($cnt_itms == 2){

echo "</tr><tr height='10'><td> </td></tr><tr>\n";

$cnt_itms = 0;

}

}

 

 

?>

</tr>

</table>

 

</td>

<td width="*"> </td>

</tr>

 

 

 

<!---------------------- BOTTOM NAVIGATION ----------------------->

<tr>

<td height="200" bgcolor="#E0E0E0" colspan="3">Contact Info -- Link to legal notices -- Copyright notice -- Sponsor Links</td>

</tr>

 

</table>

 

</body></html>

 

 

the problem is that I can't get the productcat.php page to dispaly my $custid, that is, when I click on the link that is located in the main body under Catergories

Edited by RobC73
Link to comment
Share on other sites

Maybe you were including the PHP without tags? Or the other way around...

 

<LI><A HREF="productcat.php?cat=Gas cards<? $row['prodID'] ?>">Gas cards</A></LI>

 

Put quotes around attribute values. In this case it thinks the link ends where the space is after Gas

Put array references in {}s

 

<LI><A HREF="productcat.php?cat='Gas cards.{$row['prodID']}'">Gas cards</A></LI>

 

Thanks guys but, neither of these worked :(

Link to comment
Share on other sites

1. Is your file extension ".php"?

2. What exactly does "neither of these worked" mean?

A. Page loads, but no data from MySQL?

a. Have you tried the query in mysql console, or software like phpmyadmin?

b. Have you tried debugging with mysqli_error?

B. Link fails to locate the page?

a. Have you tried setting a full URI?

b. Are you sure the file resides where you are pointing to?

Link to comment
Share on other sites

1. Is your file extension ".php"?

2. What exactly does "neither of these worked" mean?

A. Page loads, but no data from MySQL?

a. Have you tried the query in mysql console, or software like phpmyadmin?

b. Have you tried debugging with mysqli_error?

B. Link fails to locate the page?

a. Have you tried setting a full URI?

b. Are you sure the file resides where you are pointing to?

 

1. yes

2. neither worked means that I plugged in both of those exams ples into my script and, neither worked

a. page loads but, the prodID will not show up in that link <A HREF

b. I have not tried the query in mysql console, or software like phpmyadmin? (not sure how to do this)

c. link does go to page

d I have not tried debugging

e. I have tried setting the url but, I don't know if I did it correctly...example, please?

f. yes, I'm sure that the file is there

 

the <A HREF link works for the "Gas Cards" link but, I need that variable pulled from the database...actually, I need both prodID and custID which neither are showing up in the productcat.php page once the link is clicked...I hope that I explained this well

Edited by RobC73
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.