473,394 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

HELP...!!! Been trying to get this working --- am new to php

Short background... relatively new to PHP and was given a project to integrate it with a MySQL db basically just to produce reports on inventory. I had to run a query and return a value from a column. This value was then in turn passed through a hyperlink to another page as 'id'.

When I am on the new page --- I can echo $id and the value that was passed is correct. However when I try to run a mysql query using the $id variable I get nothing back. The minute I code in any text I know is in the table I am querying it works.!!!.. I have been working on this for hours and have tried every variation I could think of??? Could someone please direct me to something I am missing...

Here is the code I am using:

<?php

echo $id;


printf ("<div align=center>
<table width=600 border=1>
<tr align=center bgcolor=#999999><td>Part #</td><td>Quantity</td><td>Jobber</td><td>Extended</td><td>Part #</td><td>Quantity</td><td>Jobber</td><td>Extended</td><td>Part #</td><td>Quantity</td><td>Jobber</td><td>Extended</td>");

$result = mysql_query("SELECT * FROM `STORE_TEST` WHERE `ASC`='$id' ORDER BY `PART_NO`");

?>

as I said the previous page that links to this passes the $id through a hyperlink that is generated from a return on a query. I have tried "", [], removing quotes.. etc around the variable in the query but it will not work. I have also tried mysql_real_escape_string() etc just in hopes it might work. Have I done something wrong... I really need help because once I figure this out the project can be completed.
Apr 5 '07 #1
4 1247
ak1dnar
1,584 Expert 1GB
if you are passing the id like this
Expand|Select|Wrap|Line Numbers
  1. http://www.yourdomain.com/your_second_page.php?id=10
from your_second_page.php you can get it and assign to a variable.
[PHP]
$id = $_GET['id'] ;[/PHP]

pass this $id to query string.
Apr 5 '07 #2
ak1dnar
1,584 Expert 1GB
when you post next time read the posing guidelines carefully. as a example your title is not suited for this thread. as a result of this bad title a search engine could not locate this thread when some search around.
Apr 5 '07 #3
when you post next time read the posing guidelines carefully. as a example your title is not suited for this thread. as a result of this bad title a search engine could not locate this thread when some search around.
Sorry about that --- been working at figuring this out for a long time and read through the guidelines quickly. I will post better next time.

Thanks for your response but I did try to do this several times today:



$asc =$_GET['id];


then pass it to a query like this:

$result = mysql_query("SELECT * FROM `STORE_TEST` WHERE `ASC`='$asc' ORDER BY `PART_NO`");

but again when I attempt to output I get nothing in return. The id is being passed to the page by this code:

$result = mysql_query("SELECT `ASC`,`MANU`,SUM(`SUMJOBBER`) as totals FROM `STORE_TEST` WHERE `ASC` | 1 GROUP BY `ASC`");
$numofrows = mysql_num_rows($result);



for($i = 0; $i < $numofrows; $i++)
{
$row = mysql_fetch_array($result);
if($i % 2)
{
printf ("<tr class=trwh>\n");
} else {
printf ("<tr class=trgr>\n");
}
printf ("<td width=50><a href=detailrep.php?id=".$row['ASC']."</a>$row[ASC]</td><td padding=10> ".$row['MANU']."</td><td width=200>$ ".$row['totals']."</td>");}
?>

Here is a link to the site, if anyone as any ideas please let me know:

http://testing.thehappycomputer.com/testing4.php

Basically I am trying to pass the text of the link on this page to another php page. At the top of the second page the text seems to be passed as a value because that is an echo statement right below the title. But when I use the $var in a query it returns nothing. If I hardcode text in it works fine?
Apr 5 '07 #4
Thanks... I got it...

I assigned a text value to a variable to test and that variable worked in the query so I thought I better check how the variable was being passed. I changed some code on the first page and now the variable works that is passed to a query. I think some characters were being passed that weren't showing up on an echo statement.

I appreciate everyone's help.
Apr 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
0
by: Dale McGorman | last post by:
The following is some code that I am trying to bring over from VB 6.0, that I have working there. I am trying to get to where I can talk to a USB device. I am stuck on how to correctly pass params...
3
by: Mike | last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or comments on how to make this work I would be grateful! I have been working on this for the past 4 days and nothing I do...
6
by: Alan Silver | last post by:
Hello, I have an ASP that takes a connection string and SQL statement in the querystring and is supposed to return the XML representation of the recordset to the Response stream (don't worry,...
20
by: Jack Schitt | last post by:
I thought I was starting to get a handle on Access, until I tried doing something useful...now I'm stuck. I have a DB with two tables - to keep it simple I'll say that one is an Employee File...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
7
by: Advocated | last post by:
Hey all, thanks for taking the time to read this in the first place. Anyway, ill try and keep it simple. In my program, if i type $ man something it should read in the 2 words, man and something...
13
by: Fao | last post by:
Hello, I am having some problems with inheritance. The compiler does not not return any error messages, but when I execute the program, it only allows me to enter the number, but nothing else...
8
by: Dhananjay | last post by:
hello everyone Do you have any information how to generate a tool using .net which is used to translate the web page contents to html format. Plz reply me asap Thanks in advance Dhananjay
2
by: bozo789 | last post by:
Hi Forum, First let me begin by stating I am a student and have read the proper posting procedure concerning students. I am a begginer learning with the Miracle C Work Bench. I know my code is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.